Fix cursor jumping to end when editing the middle of the Merchant field - #98841
Draft
MelvinBot wants to merge 1 commit into
Draft
Fix cursor jumping to end when editing the middle of the Merchant field#98841MelvinBot wants to merge 1 commit into
MelvinBot wants to merge 1 commit into
Conversation
Co-authored-by: thelullabyy <thelullabyy@users.noreply.github.com>
7 tasks
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Contributor
Author
|
🤖 I re-checked the CI on this PR — no code fix is needed. When the request came in, the Current check status
Nothing to fix here — this PR just needs a reviewer's approval to go green. |
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
In the new manual expense flow, the Merchant field is a fully controlled plain
TextInputwhose displayedvaluecame directly from Onyx. Because every keystroke persists through an asynchronousOnyx.merge, the controlledvaluelagged the DOM by a tick, so when React re-rendered with the just-caught-up value, react-native-web re-asserted the input's.valueand — with noselectionprop to restore the caret — the caret snapped to the end of the field. Typing in the middle of existing text (e.g. editing "United Airlines") was therefore impossible without repositioning after each character.This mirrors the merchant text in local state and updates it synchronously in the change handler, so the controlled
valuealways matches what the user just typed and the caret stays put. Persistence to Onyx is unchanged. The local mirror is re-synced from the persisted value only while the field is not focused, so external updates (SmartScan, drafts, switching transactions) still flow in without overwriting text the user is actively typing. The standalone Merchant step page is unaffected — it already uses an uncontrolleddefaultValueinput.Fixed Issues
$ #98647
PROPOSAL: #98647 (comment)
Tests
United Airlinesin the Merchant field.UnitedandAirlines).Offline tests
Same as Tests — the field writes optimistically to Onyx, so behavior is identical offline.
QA Steps
United Airlinesin the Merchant field.PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari