Skip to content

refactor: [M3-6920] - Replace react-select with Autocomplete in 'Billing' - #10681

Merged
carrillo-erik merged 13 commits into
linode:developfrom
carrillo-erik:refactor/M3-6920
Jul 29, 2024
Merged

refactor: [M3-6920] - Replace react-select with Autocomplete in 'Billing'#10681
carrillo-erik merged 13 commits into
linode:developfrom
carrillo-erik:refactor/M3-6920

Conversation

@carrillo-erik

@carrillo-erik carrillo-erik commented Jul 15, 2024

Copy link
Copy Markdown
Contributor

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 Enhanced Select with our more versatile MUI-based Autocomplete component within the Billing feature.

Changes 🔄

List any change relevant to the reviewer.

  • Replace react-select with Autocomplete component within the Billing feature.
  • Add labels to the 'Transaction Type' and 'Transaction Date' select components in the Billing & Payment History to improve accessibility.
  • Update default exports with named exports.
  • Update unit tests.
  • Update e2e tests.

Preview 📷

Before After
before-ab after-ab

Target release date 🗓️

07/22/2024

How to test 🧪

Verification steps

(How to verify changes)

  • Verify that the Transaction Type and Transaction Date select components continue to work as expected.
  • Verify that the UI changes do not create 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 Jul 15, 2024
@carrillo-erik
carrillo-erik requested a review from a team as a code owner July 15, 2024 21:30
@carrillo-erik
carrillo-erik requested review from bnussman-akamai and hana-akamai and removed request for a team July 15, 2024 21:30
@github-actions

github-actions Bot commented Jul 15, 2024

Copy link
Copy Markdown

Coverage Report:
Base Coverage: 82.47%
Current Coverage: 82.46%

@carrillo-erik
carrillo-erik requested a review from a team as a code owner July 17, 2024 14:30
@carrillo-erik
carrillo-erik requested review from jdamore-linode and removed request for a team July 17, 2024 14:30
@carrillo-erik carrillo-erik changed the title refactor: [M3-6320] - Replace react-select with Autocomplete comp… refactor: [M3-6920] - Replace react-select with Autocomplete in 'Billing' Jul 17, 2024

@hana-akamai hana-akamai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The UI with the added labels feels a bit off to me; it pushes the Billing & Payment history header down which doesn't match the other sections. Can we add the label but just keep it visually hidden or work with UX to better integrate the label?

image

image

placeholder=" "
/>
<Select
<Autocomplete

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we hide the label, remove padding, and disableClearable to keep parity with the current UI?

Suggested change
<Autocomplete
<Autocomplete
disableClearable
textFieldProps={{
hideLabel: true,
noMarginTop: true,
}}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I updated the styles to match the other panels in the page, which removed extra white space around the Header and outline the panel. The labels for the select components are there to improve a11y (waiting feedback from UX). I added the disableClearable prop.

Comment on lines +131 to +134
export interface Item<T = string, L = string> {
label: L;
value: T;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd be in favor or removing this type and using as const on the options. It allows us to avoid this extra type and allows us to use Typescript's inference

const transactionTypeOptions = [
  { label: 'Invoices', value: 'invoice' },
  { label: 'Payments', value: 'payment' },
  { label: 'All Transaction Types', value: 'all' },
] as const;

const transactionDateOptions = [
  { label: '30 Days', value: '30 Days' },
  { label: '60 Days', value: '60 Days' },
  { label: '90 Days', value: '90 Days' },
  { label: '6 Months', value: '6 Months' },
  { label: '12 Months', value: '12 Months' },
  { label: 'All Time', value: 'All Time' },
] as const

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried implementing the types per your suggestion and struggled a bit with making things work as expected and updating the tests to match the new implementation. This latest changes fall somewhere in the middle between your suggestion and my previous changes. Please review them, if you still believe things could be done better, I'd be happy to hop on a quick huddle to discuss where I got lost.

@carrillo-erik

Copy link
Copy Markdown
Contributor Author

The UI with the added labels feels a bit off to me; it pushes the Billing & Payment history header down which doesn't match the other sections.

@hana-linode I can reduce some of the white space on the Billing & Payment History header. The other sections do not have interactive elements which is the key difference in this section with the select components.

Can we add the label but just keep it visually hidden or work with UX to better integrate the label?

I understand your points, however, not having labels on interactive elements is a ding on a11y. It's also mentioned in the epic link as part of the reasons for moving away from react-select. I can reach out to UX for alternate implementations.

@hana-akamai

Copy link
Copy Markdown
Contributor

@carrillo-erik Do we have alternate UX implementations?

@hana-akamai

Copy link
Copy Markdown
Contributor

Can we fix the mobile spacing?

  • Add more spacing under Account active to separate the account text and transaction type inputs
  • Add more spacing after Transaction Types input

image

@carrillo-erik

Copy link
Copy Markdown
Contributor Author

@hana-linode @bnussman-akamai
Please review these changes. The feedback I received from UX was that we should show the select component labels for accessibility. In order to minimize the white space the Account active since... text was moved under the panel header text.

@carrillo-erik

Copy link
Copy Markdown
Contributor Author

Can we fix the mobile spacing?

  • Add more spacing under Account active to separate the account text and transaction type inputs
  • Add more spacing after Transaction Types input

image

@hana-linode Good eye! I've added more space in mobile view.

Screenshot 2024-07-26 at 9 58 44 AM

*/
export const getCutoffFromDateRange = (
range: DateRange,
range: TransactionDateOptions,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we just pass in the value instead of an object to keep the cases more explicit?

@hana-akamai hana-akamai added Add'tl Approval Needed Waiting on another approval! and removed Ready for Review labels Jul 26, 2024
Comment on lines +75 to +77
const { data: regions } = useRegionsQuery({
transformRegionLabel: isGeckoGAEnabled,
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm a little confused on why this is in the diff

@bnussman-akamai bnussman-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved Multiple approvals and ready to merge!

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants