-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix: revalidate upon input and refocus if error occurs #23995
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, please see the additional changes. I will update the Q&A tests and re-test all platforms. |
Bump |
@@ -208,9 +208,6 @@ function BaseValidateCodeForm(props) { | |||
return; | |||
} | |||
} else { | |||
if (inputValidateCodeRef.current) { | |||
inputValidateCodeRef.current.blur(); | |||
} | |||
if (!validateCode.trim()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per this comment
Refocusing the magic code input if its incorrect seems like the expected behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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