Repository navigation
Disable locale picker while signing in - #35794
Conversation
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
|
@hoangzinh 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] |
| keyForList: language, | ||
| isSelected: preferredLocale === language, | ||
| })); | ||
| const shouldDisablePicker = account?.isLoading && account.loadingForm === (account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM); |
There was a problem hiding this comment.
I think we should move this into a util function so it can be used here as well
App/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js
Lines 108 to 109 in ebc2b7d
| }, | ||
|
|
||
| pickerSmall: (backgroundColor = theme.highlightBG) => | ||
| pickerSmall: (disabled = false, backgroundColor = theme.highlightBG) => |
There was a problem hiding this comment.
Without this the cursor would still show pointer though the picker was disabled.
| import CONST from '@src/CONST'; | ||
| import type {Account} from '@src/types/onyx'; | ||
|
|
||
| const isValidateCodeFormSubmitting = (account: Account) => |
There was a problem hiding this comment.
I think it's more proper if we can put in AccountUtils
There was a problem hiding this comment.
cc @tienifr just in case you missed this comment
There was a problem hiding this comment.
But that means we need to create a new util file.
|
@tienifr It looks like the perf-tests failed related to our change. Could you check it? |
|
@hoangzinh A little tweak proved that subscribing to a new Onyx key ( |
|
I think it might be because it re-renders the |
|
@hoangzinh this is ready for review again. |
|
@hoangzinh TS check failure is resolved after merging |
|
Hi @tienifr thanks for the update. Although it fixed perf-tests, I don't really like passing prop down to many components like this. |
|
Still following the Slack thread. |
|
@hoangzinh Perf-test was resolved finally!! |
hoangzinh
left a comment
There was a problem hiding this comment.
Overall looks good, just a small feedback
| import CONST from '@src/CONST'; | ||
| import type {Account} from '@src/types/onyx'; | ||
|
|
||
| const isValidateCodeFormSubmitting = (account: Account) => |
There was a problem hiding this comment.
Can we replace the line here by this util function?
App/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx
Lines 79 to 80 in 0b447c3
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-03-05.at.22.14.40.android.movAndroid: mWeb ChromeScreen.Recording.2024-03-05.at.22.15.49.android.chrome.moviOS: NativeScreen.Recording.2024-03-05.at.23.08.44.ios.moviOS: mWeb SafariScreen.Recording.2024-03-05.at.23.09.58.ios.safari.movMacOS: Chrome / SafariScreen.Recording.2024-03-05.at.22.07.49.web.movMacOS: DesktopScreen.Recording.2024-03-05.at.22.12.35.desktop.mov |
| keyForList: language, | ||
| isSelected: preferredLocale === language, | ||
| })); | ||
| const shouldDisablePicker = AccountUtils.isValidateCodeFormSubmitting(account ?? {}); |
There was a problem hiding this comment.
I think it's more appropriate to use defaults in the prop destructuring.
There was a problem hiding this comment.
If we assigned default value in prop destructuring, we still need to use nullish coalescing there because account is still of OnyxEntry type (nullable).
There was a problem hiding this comment.
I don't fully understand that (warning: I am not very understanding of TS currently). Is TS not able to see that an undefined account would default to an empty object in the prop destructuring? If not, how about updating isValidateCodeFormSubmitting to accept an OnyxEntry?
There was a problem hiding this comment.
how about updating isValidateCodeFormSubmitting to accept an OnyxEntry
I think we can. Then inside isValidateCodeFormSubmitting, we can early return if it's an empty object.
| shouldAllowDisabledStyle={false} | ||
| shouldShowOnlyTextWhenDisabled={false} |
There was a problem hiding this comment.
I'm not quite understanding why these two props are necessary. Can they just be derived from the isDisabled prop?
There was a problem hiding this comment.
- Without
shouldShowOnlyTextWhenDisabled, the locales would only show their key name (enores). This is for use in pages likeCompanyStep. - We don't want to show dark background for locale picker only, so we need
shouldAllowDisabledStyle.
| import type {Account} from '@src/types/onyx'; | ||
|
|
||
| const isValidateCodeFormSubmitting = (account: OnyxEntry<Account>) => | ||
| account?.isLoading && account.loadingForm === (account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM); |
There was a problem hiding this comment.
| account?.isLoading && account.loadingForm === (account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM); | |
| !!account?.isLoading && account.loadingForm === (account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM); |
To ensure it always return a boolean, not undefined
|
@tgolen looks like you forgot to merge this PR :hehe: |
|
🚀 Deployed to production by https://github.com/luacmartins in version: 1.4.50-5 🚀
|

Details
This PR disables locale picker while signing in.
Fixed Issues
$ #34645
PROPOSAL: #34645 (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)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel so 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
Screen.Recording.2024-02-05.at.14.23.47-compressed.mov
Android: mWeb Chrome
Screen.Recording.2024-02-05.at.14.25.09-compressed.mov
iOS: Native
Screen.Recording.2024-02-05.at.14.20.25-compressed.mov
iOS: mWeb Safari
Screen.Recording.2024-02-05.at.14.19.02-compressed.mov
MacOS: Chrome / Safari
Screen.Recording.2024-02-05.at.14.16.08-compressed.mov
MacOS: Desktop
Screen.Recording.2024-02-05.at.14.16.08-compressed.mov