Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplement <Select> using Headless UI
## Description I put the new implementation in `src/components`, the idea being this is where new self-contained UI components can go. `src/select.tsx` is not used by the new calculator, so it will go away when the old calculator does. This conforms to the design system with a few known differences: - When the Select is open, it doesn't have the purple outline. If you're using the keyboard, the _listbox_ gets the purple outline. This is because Headless UI focuses the listbox when you're navigating it. It is possible to remove the outline from the listbox and have the Select's button outlined when it's open, but this causes a slight flicker when the listbox closes. - The Selects should be 48px tall, but they're currently 46px to match the text input fields. I'll fix that separately. I used Floating UI to position the list so it's within the viewport. It doesn't move when you scroll the page -- I don't think that's really necessary -- but it's trivial to add if people want. ### Accessibility One notable change I made for a11y is removing the X buttons in the multiselect's tags. These tripped the "nested interactable elements" check -- a button (the X) within a button (the whole control). The Shoelace implementation was not hitting this because the top-level element is a div, not a button. We could restore the X button and do some workaround to get around the check, but it really is a nested interactable, and that's an annoying experience for screenreader users. Not sure what to do there. I don't think losing the Xs is a major loss, but could be convinced otherwise. I also removed the tooltip for the "Projects you're interested in" field, because it just said "select the projects you're interested in", which is pointless. ## Test Plan Use the element with mouse and keyboard. - Click the labels and make sure they open the element (this is a difference from Shoelace; those labels would only focus the element, not open it). Click the tooltip icons and make sure they open the tooltip and don't focus the element. - With the multiselect, click the X buttons to make sure those deselect the corresponding option. - Make the window just over 640px wide to make the multiselect super narrow, and have HVAC selected, along with something alphabetically later. This is the worst-case scenario for shrinking the element. - Change the zip code and observe the loading state in the utility selector. - With VoiceOver, make sure each form element has the label and current contents announced, with no extraneous bits announced (like icons). Honestly I'm not sure how good this screenreader experience is, although it does seem cleaner than what Shoelace gave us. Do all of the above in Chrome, Safari, Firefox, on narrow and wide layouts. Also do the non-VO stuff in MobileSafari.
- Loading branch information