fix: auto insert OTP not working#54253
Conversation
44b3ace to
7397487
Compare
Ue refs instead of state
7397487 to
eedaac8
Compare
|
@alitoshmatov Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@alitoshmatov are you able to test this feature? If not we might want to switch for a c+ who can test this in app |
|
🚧 @mountiny has triggered a test build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
|
@mountiny iOS failed to build 🥶 |
|
🚧 @mountiny has triggered a test build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-12-20.at.4.57.36.AM.movAndroid: mWeb ChromeScreen.Recording.2024-12-20.at.4.56.25.AM.moviOS: NativeScreenRecording_12-20-2024.04-31-19_1.MP4ScreenRecording_12-20-2024.04-32-44_1.MP4ScreenRecording_12-26-2024.01-53-48_1.MP4screenrecording-12-26-2024-01-48-04-1_SwQUHLrt.mp4iOS: mWeb SafariScreen.Recording.2024-12-20.at.4.53.02.AM.movMacOS: Chrome / SafariScreen.Recording.2024-12-20.at.4.45.30.AM.movscreen-recording-2024-12-26-at-12111-am_jpdpdu0c.mp4Screen.Recording.2024-12-26.at.1.30.09.AM.movScreen.Recording.2024-12-26.at.1.31.04.AM.movMacOS: DesktopScreen.Recording.2024-12-20.at.4.50.38.AM.mov |
|
@mountiny Not sure if this is a bug, but the magic code shows up in the suggestion only when I touch the input. ScreenRecording_12-20-2024.04-34-34_1.MP4 |
|
@allroundexperts yeah I observed the same (its also that way before the changes of this PR) |
|
We should probably create a follow up to fix that. |
mountiny
left a comment
There was a problem hiding this comment.
Looks good to me, but as noted in Slack. This component is used in bunch of flows. can you please test this works in them as well. Setting Copilot, Creating Expensify cards, Adding secondary login. Making login a primary login
|
@mountiny I'll post the screen recordings of these flows today. |
|
Tested all the flows on iOS native and desktop web. Added screen recordings as well. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
Reported the issue in expensify bug channel: |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.0.80-1 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.0.80-6 🚀
|
Explanation of Change
Fixes an issue where the automatically inserting the email OTP code wouldn't work on iOS.
The main problem is that when we insert the OTP code react-native's
TextInput'sonChangeTextmethod will be called in quick succession with the OTP code, see here:This is breaking the assumption of the
onChangeTextfunction inMagicCodeInput.tsx. When we have an OTP the text input's value is always""so when the user enters new text theonChangeTextwill only ever be called with one new digit string.I assume the breaking change might have been introduced in this PR:
At first I thought to adding a special condition that checks if the method was called with all required numbers, but then I've seen that the
MagicCodeInputcomponent is used in many different contexts where that assumption might be problematic.So it's a better idea to make the
onChangeTextbehave correctly in any case. The solution for this is to not depend on any state. TheonChangeTextwill be called very rapidly when inserting the OTP. Before it was relying on state to be updated, however by the time it was called the next time the state update hasn't been triggered yet.So its the safest to just use a ref here.
Fixed Issues
$ #48424
PROPOSAL:
Tests
Offline tests
n/a
QA Steps
Same as testing steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.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
Uploading ScreenRecording_12-17-2024 16-51-08_1.MP4…
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop