Fix: Form validation runs on blur in New task details page#24011
Fix: Form validation runs on blur in New task details page#24011thienlnam merged 6 commits intoExpensify:mainfrom
Conversation
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
|
@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] |
|
While testing on Safari, I found out that the active text input was forced to re-focused by this (made by #21656): App/src/components/TextInput/index.js Lines 20 to 27 in 5034433 which re-triggered Why does this not happen on Chrome? Because on Chrome , if Moreover, the original issue of #21656 only happens in mWeb Chrome. I have tried removing the changes, tested on all platforms and the app still worked as expected (i.e. keyboard still opens on focused element even when we switch to other tabs), attached video below. Thus, I suggested adding the Screen.Recording.2023-08-02.at.03.36.26.movcc @akinwale, @parasharrajat as you're the authors of the PR. |
|
Bump @eVoloshchak. |
| // Forcefully activate the soft keyboard when the user switches between tabs while input was focused. | ||
| this.removeVisibilityListener = Visibility.onVisibilityChange(() => { | ||
| if (!Visibility.isVisible() || !this.textInput || DomUtils.getActiveElement() !== this.textInput) { | ||
| if (!Browser.isMobileChrome() || !Visibility.isVisible() || !this.textInput || DomUtils.getActiveElement() !== this.textInput) { |
There was a problem hiding this comment.
This breaks the original implementation. You will find more summary on the issue and PR.
There was a problem hiding this comment.
Can you specifically point out what it did break? As I've tested on both Safari (attached above) and Chrome (attached below), it still worked.
video_2023-08-03_18-09-19.mp4
In short, the original issue only happened on Chrome, Safari would be fine without the PR. The only thing that is not right without it is:
iOS Safari: The soft keyboard does not remain open (due to a system limitation which only allows the soft keyboard to be open from a user interaction event). The screen automatically scrolls to the email input.
On iOS Safari, the keyboard still opens but screen won't scroll automatically until we type.
There was a problem hiding this comment.
I will check it and let you know later. But it was my intuition that it might break. I wasn't sure on that.
There was a problem hiding this comment.
Run the tests from #21656 and make sure they are intact.
| } | ||
| }, 200); | ||
| // Only run validation when user proactively blurs the input. | ||
| if (Visibility.isVisible() && Visibility.hasFocus()) { |
There was a problem hiding this comment.
Always prefer early returns.
There was a problem hiding this comment.
Thanks but we still have other codes below which are not relating to the check.
There was a problem hiding this comment.
Maybe move the other code above this if block if there are no issue with it and then use return.
|
@eVoloshchak Let me know your thoughts here when you have time. |
Reviewer Checklist
Screenshots/VideosWebScreen.Recording.2023-08-07.at.17.51.18.movMobile Web - Chromescreen-20230807-175626.mp4Mobile Web - SafariScreen.Recording.2023-08-07.at.17.55.19.movDesktopScreen.Recording.2023-08-07.at.17.54.26.moviOSScreen.Recording.2023-08-07.at.17.57.02.movAndroidscreen-20230807-175332.mp4 |
eVoloshchak
left a comment
There was a problem hiding this comment.
Both tests for this and #21656 are working good
|
@parasharrajat, huge thank you for weighing in on this |
|
✋ 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/thienlnam in version: 1.3.51-0 🚀
|
|
🚀 Deployed to production by https://github.com/Julesssss in version: 1.3.51-2 🚀
|
|
🚀 Deployed to staging by https://github.com/thienlnam in version: 1.3.52-0 🚀
|
|
🚀 Deployed to staging by https://github.com/thienlnam in version: 1.3.52-0 🚀
|
|
🚀 Deployed to production by https://github.com/puneetlath in version: 1.3.52-5 🚀
|
Details
Form validation runs inadvertently when the page is blurred. This PR fixes that.
Fixed Issues
$ #23552
PROPOSAL: #23552 (comment)
Tests
Offline tests
NA
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
Screen.Recording.2023-08-01.at.22.56.39.mov
Mobile Web - Chrome
video_2023-08-01_23-20-19.mp4
Mobile Web - Safari
Screen.Recording.2023-08-02.at.03.15.47.mov
Desktop
Screen.Recording.2023-08-02.at.00.11.59.mov
iOS
Screen.Recording.2023-08-01.at.23.19.50.mov
Android
Screen.Recording.2023-08-02.at.00.56.02.mov