Skip to content
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

Merged
merged 19 commits into from
Sep 13, 2024

Conversation

carrillo-erik
Copy link
Contributor

@carrillo-erik carrillo-erik commented Aug 13, 2024

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-based Autocomplete component within the Profile feature.

Changes 🔄

  • Introduce a new sxPopperComponent prop (optional) for the Autocomplete which allows custom CSS styling for the PopperComponent.
  • The PhoneVerification depended heavily on the react-select instance, and by removing it, the previous styling required to be redone. This was the reason for introducing the new sxPopperComponent prop.
  • Update TimezoneForm to TimeZoneForm.
  • Update default exports with named exports and corresponding lazy() imports.

Target release date 🗓️

09/03/2024

How to test 🧪

Verification steps

(How to verify changes)

  • Verify that the Profile feature works as expected.
  • Inspect the Profile pages for any visual regressions.

As an Author I have considered 🤔

Check all that apply

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@carrillo-erik carrillo-erik self-assigned this Aug 13, 2024
@carrillo-erik carrillo-erik marked this pull request as ready for review August 21, 2024 15:50
@carrillo-erik carrillo-erik requested a review from a team as a code owner August 21, 2024 15:50
@carrillo-erik carrillo-erik requested review from bnussman-akamai, cpathipa and mjac0bs and removed request for a team August 21, 2024 15:50
Copy link
Contributor

@cpathipa cpathipa left a 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
image

Copy link

github-actions bot commented Aug 23, 2024

Coverage Report:
Base Coverage: 86.64%
Current Coverage: 86.64%

Copy link
Contributor

@mjac0bs mjac0bs left a 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.

Screenshot 2024-08-26 at 10 03 57 AM

  • 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.
Console Errors

Screenshot 2024-08-26 at 10 18 37 AM
Screenshot 2024-08-26 at 10 19 15 AM

  • 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 = {
Copy link
Contributor

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
Screenshot 2024-08-26 at 10 09 11 AM Screenshot 2024-08-26 at 10 09 03 AM

@@ -260,32 +258,37 @@ export const PhoneVerification = ({
isPhoneInputFocused={isPhoneInputFocused}
>
<StyledSelect
Copy link
Contributor

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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've got a regression here where the thirdPartyEnabled isn't disabling an option anymore as expected. See screenshots. (I'm using my personal prod account with SSO authentication, not password auth.)

Prod This Branch
Screenshot 2024-08-26 at 10 34 45 AM Screenshot 2024-08-26 at 10 35 03 AM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regression is still happening on the current branch - I shouldn't be able to select this option.

image

Copy link
Contributor Author

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.

@carrillo-erik carrillo-erik requested a review from a team as a code owner August 27, 2024 17:44
@carrillo-erik carrillo-erik requested review from cliu-akamai and removed request for a team August 27, 2024 17:44
@carrillo-erik
Copy link
Contributor Author

@mjac0bs

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've fixed the issue with the test looking for the old enhanced select component and is now passing locally.

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.

These have been addressed with my latest changes. Thank you for inspecting the browser console and pointing these out.

Copy link
Contributor

@cpathipa cpathipa left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the UI consistent selected icon is missing for the selected option.

image

Example
image

Copy link
Contributor Author

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.

Screenshot 2024-09-04 at 9 40 53 AM
Screenshot 2024-09-04 at 9 40 16 AM

@@ -55,12 +54,18 @@ export const Question = (props: Props) => {
);
}
return (
<Select
<Autocomplete
onChange={(_, item) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, by default the the first option in the list is highlighted instead of selected option

image

Copy link
Contributor Author

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) => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, The border color for the portion of select field is not matching the rest of the field as highlighted in the screenshot.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is difficult to see, but I'm still noticing this as well.

Prod This Branch
Screenshot 2024-09-06 at 1 28 49 PM Screenshot 2024-09-06 at 1 29 12 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpathipa @mjac0bs This UI bug has finally been squashed! Feel free to also test the dark mode view.

Copy link
Contributor

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

@mjac0bs
Copy link
Contributor

mjac0bs commented Sep 3, 2024

@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.

@mjac0bs mjac0bs self-requested a review September 6, 2024 19:02
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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regression is still happening on the current branch - I shouldn't be able to select this option.

image

onChange={(_, item: SelectPhoneVerificationOption) => {
sendCodeForm.setFieldValue('iso_code', item.value);
}}
options={countries.map((country) => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is difficult to see, but I'm still noticing this as well.

Prod This Branch
Screenshot 2024-09-06 at 1 28 49 PM Screenshot 2024-09-06 at 1 29 12 PM

@carrillo-erik carrillo-erik added the Add'tl Approval Needed Waiting on another approval! label Sep 12, 2024
Copy link
Contributor

@mjac0bs mjac0bs left a 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. 👍🏼

@carrillo-erik carrillo-erik merged commit 38a0d2e into linode:develop Sep 13, 2024
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Add'tl Approval Needed Waiting on another approval! Ready for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants