Automattic / bugomattic

Bugomattic is a tool that guides bug reporters to the right actions within large, complex organizations
GNU General Public License v2.0
6 stars 0 forks source link

Add re-usable dropdown component API and sort control #82

Closed dpasque closed 1 year ago

dpasque commented 1 year ago

What Does This PR Add/Change?

In short, add's the sorting control!

For reference, see: pciE2j-1VQ-p2#comment-1745 (note, we've shifted some of the design slightly since then. Namely, we now just show the exact sort name instead of "Sort" or "Default").

To do that, I've built a re-usable component api: <Dropdown>, and its children. See the code comments for more details! In short though, it's a reusable API for building dropdown style popovers. We will use these in a couple different use cases:

  1. Our custom select controls, like this sort filter.
  2. Dropdown menus, like the links to go to the reporting flow and pick the issue type.

Those behave similarly enough that they can share a lot of the bones!

Some a11y notes.

From an a11y perspective, this sort control is technically a "select-only combobox". To learn more about comboboxes, you can read up here: https://www.w3.org/WAI/ARIA/apg/patterns/combobox/ This page has the example that is closest to our sort control: https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/

The one thing that is missing from our control is the ability to open the closed control by typing. I tried for a long time to make this work, but I was reallllly fighting the floating-ui API, and it was compromising some of the other important focus behavior. So, for now, typing works once the popover is open, but doesn't open the popover. This is technically still compliant! We can try to enhance this in the future though.

Two weird things you might note:

Testing Instructions

Issues

Related to #
Closes #62