polaris icon indicating copy to clipboard operation
polaris copied to clipboard

More filters sheet – loss of focus

Open yourpalsonja opened this issue 5 years ago • 2 comments

[Originally opened by @voiid in the web repo]

When expanding filters in the More filters section, there is inconsistent behaviour when using space vs enter to expand filter sections.

When using enter, the first option is focused and gets the expected focus style more filters with enter

When using space, the first option is focused but does not get the expected focus style. If space is pressed again, the first option is applied. If tab is pressed, focus is unexpectedly moved to the next section (because focus was actually on the expected element, just without focus styles). more filters with space

This issue exists in Polaris.

The root cause of the issue is the way that Checkbox and RadioButton render focus rings. Logic exists in these components to only show the focus-ring when using keyboard navigation due to the weird look these components have when toggling using clicks. See checkbox component and checkbox styling for how this is implemented.

Current behaviour (desired): checkbox-desired

Behaviour if we showed focus-ring at all times when checkbox is focused: checkbox-weird-focus

When filters from the More Filters section of the Filters component are expanded, they are automatically focused by the Focus component. The reason SPACE and ENTER react differently is that the ENTER key triggers the handleKeyUp that enables the focus-ring while the SPACE key does not.

There are two possible solutions to resolving this issue:

  • (Low effort, less complete as this could happen elsewhere) Remove the auto-focus of the expanded filter options as this would force users to navigate to the choice list options manually, triggering the green path for choice list focus behaviour.
  • (Higher effort but would prevent this issue in the future) Determine a way to correctly display focus by changing Checkbox and RadioButton.

yourpalsonja avatar Feb 04 '21 00:02 yourpalsonja

@lsit has an issue opened here as well.

yourpalsonja avatar Feb 04 '21 00:02 yourpalsonja

This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's design system and dev experience.

github-actions[bot] avatar Apr 08 '23 03:04 github-actions[bot]