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

feat: Replace Select with Autocomplete in FileUploadAndLabel component #2993

Merged
merged 14 commits into from
May 17, 2024

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented Apr 5, 2024

What does this PR do?

  • Replaces the MUI Select component with a MUI Autocomplete component within the FileUploadAndLabel modal
  • This is done in order to resolve the accessibility report issue "Customised Combobox" (Page 35)

Why do we need to do this?

After spending a good while amending the markup of the Select I realised it wasn't possible to meet the requirements laid out the in report. These are the two fundamental barriers I hit -

  • MUI was hardcoding role="option" on the children of the Select - we require role="group"
  • A single ul element is forced as the first child element

Using the Autocomplete allows us access to grouping, which allows us to inject some custom HTML elements in the order and location we require. I've been aiming to match the following example of a grouped listbox shared in the report - https://www.w3.org/WAI/ARIA/apg/patterns/listbox/examples/listbox-grouped/

Potential issues

As this autocomplete in a HTML Input under the hood, users can natively type here. I've disabled this to match the current user experience however this may be problematic in itself.

Update: At the dev call on 10/04 we agreed to reinstate typing (see 5769135). This is seen as an additional helpful feature, and resolves the accessibility concerns raised above.

Outstanding visual regressions

There are a few small visual disparities between the two versions which I've not yet tackled.

  • Styling for sticky group headers (do we even want them to be sticky?)
  • Transition in
  • Popper positioning
  • Focus styles
  • Element is larger (more padding) than previous iteration

Copy link

github-actions bot commented Apr 5, 2024

Removed vultr server and associated DNS entries

@DafyddLlyr DafyddLlyr force-pushed the dp/fual-autocomplete branch from c071f8f to 93fef31 Compare April 5, 2024 15:35
variant="standard"
multiple
value={tags}
<Autocomplete
Copy link
Member

Choose a reason for hiding this comment

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

I know this is still WIP - but just thought I'd flag prior MUI <Autocomplete /> a11y PRs for prop reference!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is super helpful thanks - will take a detailed look through.

@DafyddLlyr DafyddLlyr force-pushed the dp/fual-autocomplete branch from 2d33f71 to 95dfecb Compare April 8, 2024 15:48
@DafyddLlyr DafyddLlyr changed the title feat(wip): Replace Select with Autocomplete in FileUploadAndLabel component feat: Replace Select with Autocomplete in FileUploadAndLabel component Apr 10, 2024
@DafyddLlyr DafyddLlyr requested a review from a team April 10, 2024 16:10
@DafyddLlyr
Copy link
Contributor Author

Customised combobox [A]

@DafyddLlyr DafyddLlyr marked this pull request as ready for review April 10, 2024 16:15
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another nice bonus of this approach is that testing this component is much simpler! With the Select we had a fairly hard time targeting the dropdown but this is now much simpler.

* Custom Listbox component
* Used to wrap options within the autocomplete and append a custom element above the option list
*/
const ListboxComponent = forwardRef<typeof Box, PropsWithChildren>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I spent a fair bit of time trying to take this component out of the scope of SelectMultiple and pass in the closePopper() function as a prop without much luck.

const handleChange = (
_event: React.SyntheticEvent,
value: Option[],
reason: AutocompleteChangeReason,
Copy link
Contributor Author

@DafyddLlyr DafyddLlyr Apr 10, 2024

Choose a reason for hiding this comment

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

Another nice DX bonus - the Autocomplete has a much nicer API for handling changes as it expects items to be added/removed/changed.

In the Select we had to handle a single string being split up.

@DafyddLlyr DafyddLlyr force-pushed the dp/fual-autocomplete branch from 422476a to a141dd9 Compare May 3, 2024 14:03
@DafyddLlyr DafyddLlyr added the UAT (User Agent Testing) actively being tested before deployment label May 3, 2024
@DafyddLlyr
Copy link
Contributor Author

This Pizza has now been handed across to DAC for re-testing.

Copy link
Contributor

@ianjon3s ianjon3s left a 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 merge this one in and pick up any subsequent feedback from DAC as separate PRs.

@DafyddLlyr DafyddLlyr merged commit ce6e37e into main May 17, 2024
12 checks passed
@DafyddLlyr DafyddLlyr deleted the dp/fual-autocomplete branch May 17, 2024 10:23
@DafyddLlyr
Copy link
Contributor Author

Thanks @ianjon3s ! Merged, and I'll open a prod deploy shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UAT (User Agent Testing) actively being tested before deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants