fix: revalidate upon input and refocus if error occurs#23995
fix: revalidate upon input and refocus if error occurs#23995amyevans merged 6 commits intoExpensify:mainfrom samh-nl:fix/issue-21958
Conversation
|
@eVoloshchak 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] |
|
Friendly bump. |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-08-14.at.17.06.14.movMobile Web - Chromevideo_2023-08-14_17-13-22.mp4Mobile Web - SafariScreen.Recording.2023-08-14.at.17.04.42.movDesktopScreen.Recording.2023-08-14.at.17.10.54.moviOSScreen.Recording.2023-08-14.at.17.01.38.movAndroidscreen-20230814-171020.mp4 |
|
Indeed, please see the additional changes. I will update the Q&A tests and re-test all platforms. |
|
Bump |
| if (inputValidateCodeRef.current) { | ||
| inputValidateCodeRef.current.blur(); | ||
| } | ||
| if (!validateCode.trim()) { |
There was a problem hiding this comment.
As per this comment
Refocusing the magic code input if its incorrect seems like the expected behavior
There was a problem hiding this comment.
Thanks for clarifying what the correct expected behavior is. I have reverted the blur commit and pushed a new commit to reflect this. Re-testing all platforms now & updating QA tests.
|
The videos and QA steps have been updated. |
|
@samh-nl, looks good and tests well, let's change the tests section a little bit. Change step 6 to |
|
I've updated step 6 of the tests with the provided text. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/amyevans in version: 1.3.55-0 🚀
|
|
@samh-nl @eVoloshchak I am seeing one issue after the below change - after pasting the same magic code and pressing back crashes the app(reason seems to be last input not gets focused for pasting same code on error) Screen.Recording.2023-08-17.at.10.21.53.PM.mov |
|
Thanks. Interesting situation, there seems to be a conflict happening with the focusing here: https://github.com/Expensify/App/pull/23995/files#diff-913e8c5633c454fc244676c3b1bb09d85b256cc5b65763a9b02b58c58fab31bbR219 Possibly because inside Moving it down like this, the refocusing happens correctly: if (props.value === finalInput) {
validateAndSubmit(finalInput);
} else {
inputRefs.current[updatedFocusedIndex].focus();
}I am not sure yet why exactly this is blocking the refocusing happening inside |
|
I am also trying to find the exact cause but have not been successful yet. |
|
🚀 Deployed to staging by https://github.com/amyevans in version: 1.3.56-0 🚀
|
|
Here is the problem: it actually does place the focus in the last input but onFocus is not triggered. This causes The reason onFocus is not triggered is because we blur the wrong input (see below). editIndex still contains the old value of 0 (first input). But after pasting we change the focus to the last input using const blurMagicCodeInput = () => {
inputRefs.current[editIndex].blur();
setFocusedIndex(undefined);
};Why it does work the first time you copy-paste: when submitting, we call It's more easy to see what is happening by making the cursor visible (by removing inputStyle), see video: chrome_sJ0rmQw89q.mp4The solution I mentioned earlier (see below) still seems to be valid and now there's a good understanding why. It correctly blurs the input, causing onFocus to be triggered when the focus is returned. It still needs to be tested on all platforms, and I will give an update asap. if (props.value === finalInput) {
validateAndSubmit(finalInput);
} else {
inputRefs.current[updatedFocusedIndex].focus();
} |
|
@samh-nl Just flagging that there's a deploy blocker related to this: if the code is entered implicitly via deeplink or from another tab, the last input is still focused (even though the input itself is empty). There's a PR to fix it, but we're still having some issues with the fix there that look like they might get sorted with your proposed solution above. If you have a minute to check, I'd appreciate it! |
|
I think we should revert this PR to unblock the deploy, and proceed once @samh-nl has had a chance to redo the PR incorporating the above changes. That will give us more time to test without the time pressure of a blocked deploy. This was an edge case to begin with so let's not merge something hastily unnecessarily. |
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.56-24 🚀
|
Details
After submitting the magic code input form, the input should be focused again if an error occurs.
Fixed Issues
$ #21958
PROPOSAL: #21958 (comment)
Tests
Offline tests
N/A: Sign in is not available while offline.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)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
Web
Web.Screen.Recording.2023-08-10.at.14.43.27.mp4
Mobile Web - Chrome
mWeb.Chrome.Screen.Recording.2023-08-10.at.15.18.19.mp4
Mobile Web - Safari
mWeb.Safari.Screen.Recording.2023-08-10.at.16.22.56.mp4
Desktop
Desktop.Screen.Recording.2023-08-10.at.14.47.33.mp4
iOS
Native.iOS.Screen.Recording.2023-08-10.at.16.16.29.mp4
Android
Native.Android.Screen.Recording.2023-08-10.at.15.14.30.mp4