Skip to content

[WC-3015] Improve dropdown filter #1732

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open

[WC-3015] Improve dropdown filter #1732

wants to merge 17 commits into from

Conversation

r0b1n
Copy link
Collaborator

@r0b1n r0b1n commented Jun 30, 2025

Pull request type

Bug fix (non-breaking change which fixes an issue)

New feature (non-breaking change which adds functionality)

Breaking change (fix or feature that would cause existing functionality to change)


Description

Various improvements for dropdown widget.

  • Separate captions for Empty selection, Empty option and Input placeholder. Fully customizable now.
  • [Tag] Shrink input if not focused (prevents empty line when some items were selected)
  • [Tag] Fix 🤞 arrow keys and backspace behavior (was not working in some cases)
  • Clicking whole widget area activates the widget, no dead-zone in the widget at the paddings (previously clicking near the widget border was not opening the widget)
  • [Tag] Don't close popup if input is clicked while already in focus (this is more user friendly)
  • [Tag] Add highlight color for tags if selected via mouse clicks (had no visual sign if was focused not with keyboard, but had a border highlight when focused via keyboard, that stayed as is)
  • Focus highlight for clear button (it had no visual sign it was focused)
  • Don't focus on input when clear button is clicked. This allows clearing without focusing in the input when widget is not active.
  • Remove empty item from multiselect, it only makes sense for non-filterable singe select.
  • Fix clear and arrow buttons separator (it was not in full height)

Breaking change

The input text are now changed and it will affect users, they have to revisit and configure text to their needs.

@r0b1n r0b1n requested a review from a team as a code owner June 30, 2025 16:05
@r0b1n r0b1n force-pushed the improve-dropdown-filter branch 3 times, most recently from 5ceb469 to 0cd24af Compare July 2, 2025 09:21
@r0b1n r0b1n changed the title [WC-315] Improve dropdown filter [WC-3015] Improve dropdown filter Jul 2, 2025
@r0b1n r0b1n force-pushed the improve-dropdown-filter branch 2 times, most recently from 4b3d234 to d92da8a Compare July 3, 2025 12:48
gjulivan
gjulivan previously approved these changes Jul 3, 2025
<button className={cls.toggle} {...getToggleButtonProps({ "aria-label": "Show options" })}>
<Arrow className={cls.stateIcon} />
</button>
<OptionsWrapper
cls={cls}
label={inputLabel}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we set the input label on the Options menu? This seems very counterintuitive.

Copy link
Collaborator Author

@r0b1n r0b1n Jul 4, 2025

Choose a reason for hiding this comment

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

This is the logic behind downshiftjs, it was putting aria-labeledby on menu as well. And because we didn't render label it was a dangling property, pointing to a non-existing element by id. So I replaced it with explicit aria-label, which should have the same effect downshiftjs intended to have. Check this line to see how snapshot changed.

Other option is to explicitly unset this aria-labeledby that is coming from getMenuProps, so it won't have a label, but I thought that downshiftjs has a good reason to label menu as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, since we're using it here without the label provided by downshift I would also say this makes more sense. We could also consider having the label from downshift there but invisible? But to me this aria-label approach makes more sense. Let me know what you think @iobuhov

@@ -142,13 +146,31 @@
</property>
</propertyGroup>
</propertyGroup>
<propertyGroup caption="Accessibility">
<propertyGroup caption="Advanced">
<propertyGroup caption="Accessibility">
<property key="ariaLabel" type="textTemplate" required="false">
<caption>Input caption</caption>
<description>Assistive technology will read this upon reaching the input element.</description>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this description is not relevant anymore. In case of simple select, aria label is added to the menu, which is confusing. Should we change description?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is probably still holds, as if this says something like "Select color", it will be read upon reaching the filter widget and also while user selects options from the list, and the list is also labeled "Select color", which is I think a11y implementation details not worth mentioning here.

showSeparator={false}
visible={!props.empty}
/>
<ClearButton cls={cls} onClick={props.onClear} visible={!props.empty} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just tested the combobox and found that after clearing selection, keyboard navigation breaks because focus is not returned to the trigger element. Focus is rests to body

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, thanks! Pushed a fix just now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants