-
Notifications
You must be signed in to change notification settings - Fork 352
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
refactor: [M3-6908] - Replace react-select in Profile #10780
refactor: [M3-6908] - Replace react-select in Profile #10780
Conversation
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.
@carrillo-erik The build failed, not able to load the module TimeZoneForm
file name should be renamed to TimeZoneForm
instead of TimezoneForm
Coverage Report: ✅ |
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 the clean up with Autocompletes. I'm seeing a few things left to address here:
- There's one more failure that is legit and a result of these changes:
security-questions.spec.ts
. It's still looking for the enhanced select.
- I'm seeing a lot of console warnings about uncontrolled vs controlled when changing the values of the Autocomplete fields. I'd check to see how we're handling this in other uses of Autocomplete throughout the app.
- Styling regressions on Phone Verification field (see comments)
- Regression with disabled state on the LISH Authentication options (see comment)
@@ -166,22 +175,10 @@ export const PhoneVerification = ({ | |||
); | |||
}; | |||
|
|||
const customStyles = { |
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 noticed a regression with this field in dark mode; it's much more difficult to tell in light mode unless you fill the entire textfield with text and notice that it doesn't go all the way to the edge of the field. It looks like maybe the width of the container isn't correct anymore because the background doesn't fill the input area.
Prod | This Branch |
---|---|
@@ -260,32 +258,37 @@ export const PhoneVerification = ({ | |||
isPhoneInputFocused={isPhoneInputFocused} | |||
> | |||
<StyledSelect |
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.
In prod, we couldn't erase the flag, but now we can, and that leads to some slightly odd behavior where, if the flag is cleared, the country code is still there. Also, the placeholder "Select" gets cut off. Are we able to make the country non-clearable?
Light mode is this branch, dark mode is prod:
Screen.Recording.2024-08-26.at.10.15.08.AM.mov
export const LishSettings = () => { | ||
const theme = useTheme(); | ||
const { data: profile, isLoading } = useProfile(); | ||
const { mutateAsync: updateProfile } = useMutateProfile(); | ||
const [submitting, setSubmitting] = React.useState<boolean>(false); | ||
const [errors, setErrors] = React.useState<APIError[]>([]); | ||
const [success, setSuccess] = React.useState<string>(); | ||
const thirdPartyEnabled = profile?.authentication_type !== 'password'; |
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.
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.
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.
@mjac0bs After the brief exchange we had, I went and set up SSO auth on my account and was able to verify that my latest changes resolved this issue.
I've fixed the issue with the test looking for the old enhanced select component and is now passing locally.
These have been addressed with my latest changes. Thank you for inspecting the browser console and pointing these out. |
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.
Functionality LGTM! left few comments related to styling.
@@ -55,12 +54,18 @@ export const Question = (props: Props) => { | |||
); | |||
} | |||
return ( | |||
<Select | |||
<Autocomplete |
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.
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.
@cpathipa I do see the point that you're making. However, after investigating, it appears that this is caused by the underlying usage of formik. For example, you'll notice the same discrepancy in the Image and Region select components in the Linode Create flow. This might be better suited for a separate ticket to identify which components need to be updated to use formik to maintain consistency.
@@ -55,12 +54,18 @@ export const Question = (props: Props) => { | |||
); | |||
} | |||
return ( | |||
<Select | |||
<Autocomplete | |||
onChange={(_, item) => { |
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.
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.
@cpathipa Thanks for catching this. I've made the necessary changes to highlight the most recent selections rather than the first option.
onChange={(_, item: SelectPhoneVerificationOption) => { | ||
sendCodeForm.setFieldValue('iso_code', item.value); | ||
}} | ||
options={countries.map((country) => ({ |
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.
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.
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.
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, thank you!
I was seeing one weird thing here, and it might have to do with the default Autocomplete behavior: the flag icon is now selected when the dropdown is open. In dark mode, this gives the appearance that the flag's background is white until a selection is made or the user moves the cursor.
Screen.Recording.2024-09-12.at.10.57.04.AM.mov
@carrillo-erik Looks like there's a merge conflict that will need to be resolved. I'll take a final pass at this once this branch is up to date and Chandra's UX feedback is addressed. Thanks for addressing initial feedback. |
export const LishSettings = () => { | ||
const theme = useTheme(); | ||
const { data: profile, isLoading } = useProfile(); | ||
const { mutateAsync: updateProfile } = useMutateProfile(); | ||
const [submitting, setSubmitting] = React.useState<boolean>(false); | ||
const [errors, setErrors] = React.useState<APIError[]>([]); | ||
const [success, setSuccess] = React.useState<string>(); | ||
const thirdPartyEnabled = profile?.authentication_type !== 'password'; |
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.
...er/src/features/Profile/AuthenticationSettings/PhoneVerification/PhoneVerification.styles.ts
Show resolved
Hide resolved
packages/manager/cypress/e2e/core/account/security-questions.spec.ts
Outdated
Show resolved
Hide resolved
onChange={(_, item: SelectPhoneVerificationOption) => { | ||
sendCodeForm.setFieldValue('iso_code', item.value); | ||
}} | ||
options={countries.map((country) => ({ |
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.
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.
Noted one minor thing about dark mode county code selection, but otherwise it looks like feedback has been addressed here and relevant tests are passing. 👍🏼
Description 📝
This PR helps remove part of the react-select dependency for accessibility reasons and to consolidate our usage of third-party libraries. In particular, it replaces the
EnhancedSelect
with our more versatile MUI-basedAutocomplete
component within theProfile
feature.Changes 🔄
sxPopperComponent
prop (optional) for theAutocomplete
which allows custom CSS styling for thePopperComponent
.PhoneVerification
depended heavily on thereact-select
instance, and by removing it, the previous styling required to be redone. This was the reason for introducing the newsxPopperComponent
prop.TimezoneForm
toTimeZoneForm
.default
exports withnamed
exports and correspondinglazy()
imports.Target release date 🗓️
09/03/2024
How to test 🧪
Verification steps
(How to verify changes)
Profile
feature works as expected.Profile
pages for any visual regressions.As an Author I have considered 🤔
Check all that apply