Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAID] [$250] Composer - Console error shows up when pasting the same text in the composer #51466

Closed
1 of 8 tasks
izarutskaya opened this issue Oct 25, 2024 · 22 comments
Closed
1 of 8 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@izarutskaya
Copy link

izarutskaya commented Oct 25, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.0.54-0
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): applausetester+kh2010001@applause.expensifail.com
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Type anything in the composer.
  3. Highlight all the content.
  4. Copy the content.
  5. While the content is still highlighted, paste the same content.

Expected Result:

No console error will show up.

Actual Result:

Console error shows up when pasting the same text in the composer

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6645374_1729849788350.error.mp4

Bug6645374_1729849788357!staging.new.expensify.com-1729840230855.txt

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021851405996383084182
  • Upwork Job ID: 1851405996383084182
  • Last Price Increase: 2024-10-29
  • Automatic offers:
    • jjcoffee | Reviewer | 104665940
    • nkdengineer | Contributor | 104665943
Issue OwnerCurrent Issue Owner: @strepanier03
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 25, 2024
Copy link

melvin-bot bot commented Oct 25, 2024

Triggered auto assignment to @strepanier03 (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@NJ-2020
Copy link
Contributor

NJ-2020 commented Oct 27, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Composer - Console error shows up when pasting the same text in the composer

What is the root cause of that problem?

When we pasting the same text into the composer, the handleOnChangeText function get invoked

We use the parseInnerHTMLToText function to parse from innerHTML to text value and pass the inputType value here

When pasting the same text the inputType value returns undefined value
Inside the parseInnerHTMLToText function we check if there's no changes inside the input value and the inputType value contains delete value then we will run the below code:

if (text === target.value && inputType.includes('delete')) {
  text = text.slice(0, cursorPosition - 1) + text.slice(cursorPosition);
}

The RCA is on the if the condition, when we paste the same text, the if condition will check if the input value doest not change and the inputType value contains delete then we will run the above code

Since inputType value is undefined, we did not add ? before using the includes method it will throw an error

What changes do you think we should make in order to solve the problem?

We should add ? before the includes method

if (text === target.value && inputType?.includes('delete')) {
  text = text.slice(0, cursorPosition - 1) + text.slice(cursorPosition);
}

What alternative solutions did you explore? (Optional)

@melvin-bot melvin-bot bot added the Overdue label Oct 28, 2024
Copy link

melvin-bot bot commented Oct 28, 2024

@strepanier03 Whoops! This issue is 2 days overdue. Let's get this updated quick!

@strepanier03
Copy link
Contributor

Reproduced without issue,
image

Figuring out project now.

@melvin-bot melvin-bot bot removed the Overdue label Oct 29, 2024
@strepanier03
Copy link
Contributor

cursorUtils.js:24 Uncaught IndexSizeError: Failed to execute 'setStart' on 'Range': The offset 62 is larger than the node's length (0).
at A (cursorUtils.js:24:11)
at MarkdownTextInput.web.js:366:9
at Object.Te (react-dom.production.min.js:54:317)
at $e (react-dom.production.min.js:54:471)
at react-dom.production.min.js:55:35
at Fr (react-dom.production.min.js:105:68)
at Lr (react-dom.production.min.js:106:380)
at react-dom.production.min.js:117:104
at ll (react-dom.production.min.js:273:42)
at De (react-dom.production.min.js:52:375)

@strepanier03 strepanier03 added the External Added to denote the issue can be worked on by a contributor label Oct 29, 2024
@melvin-bot melvin-bot bot changed the title Composer - Console error shows up when pasting the same text in the composer [$250] Composer - Console error shows up when pasting the same text in the composer Oct 29, 2024
Copy link

melvin-bot bot commented Oct 29, 2024

Job added to Upwork: https://www.upwork.com/jobs/~021851405996383084182

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 29, 2024
Copy link

melvin-bot bot commented Oct 29, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @jjcoffee (External)

@nkdengineer
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Console error shows up when pasting the same text in the composer

What is the root cause of that problem?

The problem is inputType can be undefined and in the case the current text and the past text is the same we go to this logic and the error appears because we use includes function with undefined value.

https://github.com/Expensify/react-native-live-markdown/blob/4e4f13d744dc05685c7a0907a086e5f9616906e2/src/web/utils/inputUtils.ts#L107

What changes do you think we should make in order to solve the problem?

It's a bad type declear here since inputType can be undefined, we should change this to

interface MarkdownNativeEvent extends Event {
  inputType?: string;
}

https://github.com/Expensify/react-native-live-markdown/blob/4e4f13d744dc05685c7a0907a086e5f9616906e2/src/MarkdownTextInput.web.tsx#L39-L41

Then change the inputType to optional here

https://github.com/Expensify/react-native-live-markdown/blob/4e4f13d744dc05685c7a0907a086e5f9616906e2/src/web/utils/inputUtils.ts#L40

And add the safe check here

if (text === target.value && inputType?.includes('delete')) {

https://github.com/Expensify/react-native-live-markdown/blob/4e4f13d744dc05685c7a0907a086e5f9616906e2/src/web/utils/inputUtils.ts#L107

With this change, we can make sure there's not the same case can happen in the feature when we get the input type from nativeEvent

What alternative solutions did you explore? (Optional)

NA

@jjcoffee
Copy link
Contributor

Two pretty similar proposals here, but @nkdengineer's proposal includes the important extra detail of fixing up inputType's type declaration so I think we're going to go with theirs.

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Oct 30, 2024

Triggered auto assignment to @mountiny, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 30, 2024
Copy link

melvin-bot bot commented Oct 30, 2024

📣 @jjcoffee 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Oct 30, 2024

📣 @nkdengineer 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@nkdengineer
Copy link
Contributor

@jjcoffee this PR is ready for review

@tomekzaw
Copy link
Contributor

cc @Skalakid and @BartoszGrajdek

@tomekzaw
Copy link
Contributor

tomekzaw commented Nov 4, 2024

FYI Expensify/react-native-live-markdown#531 has been merged and released in 0.1.180.

@melvin-bot melvin-bot bot added the Overdue label Nov 4, 2024
@jjcoffee
Copy link
Contributor

jjcoffee commented Nov 4, 2024

@nkdengineer Can you raise the App PR when you get a chance? 🙏

@melvin-bot melvin-bot bot removed the Overdue label Nov 4, 2024
@nkdengineer
Copy link
Contributor

Will open the App PR tomorrow.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 Weekly KSv2 labels Nov 6, 2024
@melvin-bot melvin-bot bot changed the title [$250] Composer - Console error shows up when pasting the same text in the composer [HOLD for payment 2024-11-20] [$250] Composer - Console error shows up when pasting the same text in the composer Nov 13, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 13, 2024
Copy link

melvin-bot bot commented Nov 13, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Nov 13, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.60-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-11-20. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Nov 13, 2024

@jjcoffee @strepanier03 @jjcoffee The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Nov 19, 2024
@jjcoffee
Copy link
Contributor

jjcoffee commented Nov 19, 2024

BugZero Checklist:

  • [Contributor] Classify the bug:
Bug classification

Source of bug:

  • 1a. Result of the original design (eg. a case wasn't considered)
  • 1b. Mistake during implementation
  • 1c. Backend bug
  • 1z. Other:

Where bug was reported:

  • 2a. Reported on production
  • 2b. Reported on staging (deploy blocker)
  • 2c. Reported on both staging and production
  • 2d. Reported on a PR
  • 2z. Other:

Who reported the bug:

  • 3a. Expensify user
  • 3b. Expensify employee
  • 3c. Contributor
  • 3d. QA
  • 3z. Other:
  • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

    Link to comment: https://github.com/Expensify/react-native-live-markdown/pull/462/files#r1848625937

  • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

    Link to discussion: N/A

  • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

  • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

    Link to issue:

Regression Test Proposal

Test:

  1. Type anything in the composer.
  2. Highlight all the content.
  3. Copy the content.
  4. While the content is still highlighted, paste the same content.
  5. Verify that: No console error shows up.

Do we agree 👍 or 👎

@strepanier03 strepanier03 changed the title [HOLD for payment 2024-11-20] [$250] Composer - Console error shows up when pasting the same text in the composer [Payment 2024-11-20] [$250] Composer - Console error shows up when pasting the same text in the composer Nov 20, 2024
@strepanier03 strepanier03 changed the title [Payment 2024-11-20] [$250] Composer - Console error shows up when pasting the same text in the composer [PAID] [$250] Composer - Console error shows up when pasting the same text in the composer Nov 21, 2024
@strepanier03
Copy link
Contributor

I've made the reg test, paid and closed both contracts and updated the title.

Thanks again, everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
Status: Done
Development

No branches or pull requests

7 participants