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

[HOLD for payment 2024-11-29] [HOLD RN Upgrade] Android - Invoice - In invoice details page, reopening amount field shows cursor at beginning #50055

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

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 2, 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.43-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team

Action Performed:

  1. Launch app
  2. Log in with new expensifail account
  3. Tap fab -- new workspace - more features - enable invoice
  4. Navigate to LHN
  5. Tap fab - send invoice
  6. Enter an amount and tap next
  7. Select a user
  8. Tap next
  9. Enter company name and address
  10. Tap send invoice
  11. Open invoice - amount
  12. Reopen the amount field

Expected Result:

In invoice details page, reopening amount field must not show cursor at beginning

Actual Result:

In invoice details page, reopening amount field shows cursor at beginning

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6621403_1727807381706.Screenrecorder-2024-10-01-23-50-53-99_compress_1.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @sakluger
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Oct 2, 2024
Copy link

melvin-bot bot commented Oct 2, 2024

Triggered auto assignment to @sakluger (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.

@lanitochka17
Copy link
Author

@sakluger FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@sakluger sakluger added the External Added to denote the issue can be worked on by a contributor label Oct 2, 2024
Copy link

melvin-bot bot commented Oct 2, 2024

Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

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

melvin-bot bot commented Oct 2, 2024

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

@nkdengineer
Copy link
Contributor

Proposal

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

In invoice details page, reopening amount field shows cursor at beginning

What is the root cause of that problem?

The weird bug happens by the old HOC withOnyx in IOURequestStepAmount. That causes the currency to flicker from USD to the current currency

Screen.Recording.2024-10-03.at.15.10.49.mov

const IOURequestStepAmountWithOnyx = withOnyx<IOURequestStepAmountProps, IOURequestStepAmountOnyxProps>({

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

Remove withOnyx in IOURequestStepAmount and use useOnyx. The test branch here

const IOURequestStepAmountWithOnyx = withOnyx<IOURequestStepAmountProps, IOURequestStepAmountOnyxProps>({

What alternative solutions did you explore? (Optional)

Result

Screen.Recording.2024-10-03.at.15.07.32.mov

@situchan
Copy link
Contributor

situchan commented Oct 3, 2024

@nkdengineer thanks for the proposal. The root cause is not clear. Please explain why this bug happens only on android.
I tested your branch and bug is still reproducible.

@nkdengineer
Copy link
Contributor

@situchan Can you share the video that you tested in my test branch.

@nkdengineer
Copy link
Contributor

The root cause is not clear. Please explain why this bug happens only on android.

@situchan That is because the withOnyx is outdated and on Android, there are more delays on the other platform when we merge the Onyx data then which can affect the weird lifecycle on Android.

We can see the log here in IOURequestStepAmount, this component is mounted and unmounted two times when we open this page

Screenshot 2024-10-04 at 15 03 49

And here is the result when we use useOnyx
Screenshot 2024-10-04 at 15 03 15

@QichenZhu
Copy link
Contributor

QichenZhu commented Oct 4, 2024

Proposal

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

Sometimes the caret in the currency amount input is initially at the beginning instead of the end.

What is the root cause of that problem?

The native component ReactEditText is not initially selectable. It only becomes selectable after it is attached to window.

https://github.com/facebook/react-native/blob/699f73a6b0734fe716b01d263e9579bca38c4652/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java#L1053C3-L1060

public void onAttachedToWindow() {
  super.setTextIsSelectable(true);

TextInput component sets the selection in the code below.

https://github.com/facebook/react-native/blob/699f73a6b0734fe716b01d263e9579bca38c4652/packages/react-native/Libraries/Components/TextInput/TextInput.js#L1104-L1132

useLayoutEffect(() => {
  viewCommands.setTextAndSelection(

The execution order of making it selectable and setting the selection is random. If making it selectable runs after setting the selection, the selection resets to the beginning.

To validate this, we can print logs before and after setTextIsSelectable().

FLog.w(TAG, "Before: selectable = " + isTextSelectable() + " selectionStart = " + getSelectionStart() + " selectionEnd = " + getSelectionEnd());
super.setTextIsSelectable(true);
FLog.w(TAG, "After: selectable = " + isTextSelectable() + " selectionStart = " + getSelectionStart() + " selectionEnd = " + getSelectionEnd());

We’ll notice when this bug occurs, the selection is at the right (Before: selectable = false selectionStart = 4 selectionEnd = 4) then resets to the left (After: selectable = true selectionStart = 0 selectionEnd = 0).

This is not always reproducible and happened in my tests only about 1 out of 10 times.

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

We could add a patch to node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java to save the selection before calling setTextIsSelectable() and restore it afterward.

int prevSelectionStart = getSelectionStart();
int prevSelectionEnd = getSelectionEnd();
super.setTextIsSelectable(true);
setSelection(prevSelectionStart, prevSelectionEnd);

What alternative solutions did you explore? (Optional)

N/A

Copy link

melvin-bot bot commented Oct 7, 2024

@sakluger, @situchan Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Oct 7, 2024
@situchan
Copy link
Contributor

situchan commented Oct 7, 2024

@nkdengineer here's video:

bug.mp4

@QichenZhu if it's RN bug, it should be fixed in upstream. Can you please create issue in RN?

@melvin-bot melvin-bot bot removed the Overdue label Oct 7, 2024
@QichenZhu
Copy link
Contributor

Can you please create issue in RN?

@situchan Sure, I'll try to make a reproducer as required by RN first.

BTW, I don’t expect them to process it quickly. For reference, the contributor from issue #21219 created a PR for them over a year ago, and it's still under review.

@QichenZhu
Copy link
Contributor

@situchan Here's a minimal reproduction:

import { TextInput } from 'react-native';
import { useEffect, useRef} from 'react';

export default function App() {
  const input = useRef(null);
  useEffect(() => { setTimeout(() => input.current?.focus(), 1000); }, []);
  return <TextInput ref={input} value='1.00' selection={{start: 4, end: 4}} />;
}

Reproduction Steps

  1. Clone the reproducer https://github.com/QichenZhu/reproducer-react-native-textinput.git

  2. Build the Android app with New Arch enabled.

cd ReproducerApp
yarn
yarn android
  1. Start Metro.
npx react-native start
  1. Launch the app.

  2. Wait a second.

Expected result: The caret is at the end.

Actual result: The caret is at the beginning.

23_1728368555.mp4

@situchan
Copy link
Contributor

situchan commented Oct 8, 2024

@QichenZhu thanks. Let's try to fix upstream first. If it takes too long, we can consider patch.

@QichenZhu
Copy link
Contributor

The upstream issue facebook/react-native#46943 is resolved and the PR facebook/react-native#46948 is merged. It may take one or two months for the changes to be included in a release.

@sakluger
Copy link
Contributor

@situchan what do you think - should we move to monthly and wait for the upstream PR to be released? That's what I think we should do, since this bug isn't a huge impact to customers.

@melvin-bot melvin-bot bot added the Overdue label Oct 10, 2024
@situchan
Copy link
Contributor

Let's assign @QichenZhu since their upstream PR was merged.
And hold this for RN upgrade.
Proposal: #50055 (comment)
🎀👀🎀 C+ reviewed

@melvin-bot melvin-bot bot removed the Overdue label Oct 14, 2024
Copy link

melvin-bot bot commented Oct 14, 2024

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

@sakluger
Copy link
Contributor

sakluger commented Nov 6, 2024

@situchan do you still think we should continue holding for the upstream fix to be released, or should we try fixing immediately?

@melvin-bot melvin-bot bot removed the Overdue label Nov 6, 2024
@QichenZhu
Copy link
Contributor

@situchan mentioned he was on parental leave. Not sure if he’s back yet. @sakluger @aldo-expensify Could you respond to the above 2 comments?

@aldo-expensify
Copy link
Contributor

@QichenZhu I understand that the fix you did here has not been released yet, correct?
Do we need to do a "open a pick request" for your fix?

@QichenZhu
Copy link
Contributor

QichenZhu commented Nov 13, 2024

@aldo-expensify

I understand that the fix you did here has not been released yet, correct?

No, it hasn’t been released yet.

Do we need to do a "open a pick request" for your fix?

Yes, I think so if we want it included in 0.75 or 0.76. Otherwise, it's expected to be released in 0.77.

@aldo-expensify
Copy link
Contributor

Do we need to do a "open a pick request" for your fix?

Yes, I think so if we want it included in 0.75 or 0.76, but I'm not sure how long they'll take to process it.

Requested here: reactwg/react-native-releases#622, maybe lets give it a week and then we reassess?

@ikevin127
Copy link
Contributor

Coming from issue #52029, it was decided to move forward with creating a patch with the fixes already merged into react-native because of the lengthy timeline it would take E/App to upgrade to the future version of react-native where the fixes will be available. The patch will also fix this issue, therefore I added it to the PRs Fixed Issues section which triggered the automation.

@aldo-expensify
Copy link
Contributor

I think we should close this issue... this #52029 is pretty a dupe of this one (same root cause). Is anyone missing compensation for this issue or can I just close it?

@ikevin127
Copy link
Contributor

Compensation will be handled in #52029, so I'd say we can close this one.

@QichenZhu
Copy link
Contributor

I think we should close this issue... this #52029 is pretty a dupe of this one (same root cause). Is anyone missing compensation for this issue or can I just close it?

@aldo-expensify @sakluger I’m not sure if I should be paid since I only submitted a PR to react-native, not to our repo. What do you think?

@sakluger
Copy link
Contributor

@QichenZhu we can compensate you for your work on the upstream PR. Please let me know once you've accepted the below offer.

Summarizing payment on this issue:

Contributor: @QichenZhu $250, sent offer via Upwork: https://www.upwork.com/nx/wm/offer/104978993

@sakluger sakluger added Daily KSv2 and removed Weekly KSv2 labels Nov 19, 2024
@QichenZhu
Copy link
Contributor

Thank you so much! Offer accepted. @sakluger

@sakluger
Copy link
Contributor

Of course!

I've paid out the offer, so we're good to close this issue now.

@github-project-automation github-project-automation bot moved this from Bugs and Follow Up Issues to Done in [#whatsnext] #expense Nov 20, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Daily KSv2 labels Nov 22, 2024
@melvin-bot melvin-bot bot changed the title [HOLD RN Upgrade] Android - Invoice - In invoice details page, reopening amount field shows cursor at beginning [HOLD for payment 2024-11-29] [HOLD RN Upgrade] Android - Invoice - In invoice details page, reopening amount field shows cursor at beginning Nov 22, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Nov 22, 2024
Copy link

melvin-bot bot commented Nov 22, 2024

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

Copy link

melvin-bot bot commented Nov 22, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.65-5 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-29. 🎊

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

  • @QichenZhu requires payment (Needs manual offer from BZ)
  • @situchan requires payment (Needs manual offer from BZ)

Copy link

melvin-bot bot commented Nov 22, 2024

@aldo-expensify @sakluger @QichenZhu / @situchan 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]

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. External Added to denote the issue can be worked on by a contributor Weekly KSv2
Projects
Status: Done
Development

No branches or pull requests

7 participants