-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
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] |
src/components/LocalePicker.tsx
Outdated
@@ -31,6 +34,7 @@ function LocalePicker({preferredLocale = CONST.LOCALES.DEFAULT, size = 'normal'} | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
const isValidateCodeFormSubmitting = | |
props.account.isLoading && props.account.loadingForm === (props.account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM); |
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.
Updated!
@@ -695,7 +695,7 @@ const styles = (theme: ThemeColors) => | |||
width: '100%', | |||
}, | |||
|
|||
pickerSmall: (backgroundColor = theme.highlightBG) => | |||
pickerSmall: (disabled = false, backgroundColor = theme.highlightBG) => |
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.
do we need this change?
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.
Without this the cursor would still show pointer though the picker was disabled.
src/libs/FormUtils.ts
Outdated
import CONST from '@src/CONST'; | ||
import type {Account} from '@src/types/onyx'; | ||
|
||
const isValidateCodeFormSubmitting = (account: Account) => |
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.
I think it's more proper if we can put in AccountUtils
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.
cc @tienifr just in case you missed this comment
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.
But that means we need to create a new util file.
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.
Updated.
@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!! |
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.
Overall looks good, just a small feedback
src/libs/AccountUtils.ts
Outdated
import CONST from '@src/CONST'; | ||
import type {Account} from '@src/types/onyx'; | ||
|
||
const isValidateCodeFormSubmitting = (account: Account) => |
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.
Can we replace the line here by this util function?
App/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.tsx
Lines 79 to 80 in 0b447c3
const isValidateCodeFormSubmitting = | |
account?.isLoading && account?.loadingForm === (account?.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM); |
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.
Updated!
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 |
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.
LGTM
src/components/LocalePicker.tsx
Outdated
@@ -31,6 +35,7 @@ function LocalePicker({preferredLocale = CONST.LOCALES.DEFAULT, size = 'normal'} | |||
keyForList: language, | |||
isSelected: preferredLocale === language, | |||
})); | |||
const shouldDisablePicker = AccountUtils.isValidateCodeFormSubmitting(account ?? {}); |
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.
I think it's more appropriate to use defaults in the prop destructuring.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
Updated!
shouldAllowDisabledStyle={false} | ||
shouldShowOnlyTextWhenDisabled={false} |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Without
shouldShowOnlyTextWhenDisabled
, the locales would only show their key name (en
ores
). This is for use in pages likeCompanyStep
. - We don't want to show dark background for locale picker only, so we need
shouldAllowDisabledStyle
.
src/libs/AccountUtils.ts
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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! Updated.
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 @tienifr
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.
Nice change. Thank you!
@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 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)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.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
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