oui icon indicating copy to clipboard operation
oui copied to clipboard

[Fix] Theme selector incorrectly focus on first item after selection

Open willie-hung opened this issue 1 year ago • 8 comments

Description

This PR removes the initial focusing state when opening up the theme selector popup.

Issues Resolved

Fixes #1163

Demo

Before

https://github.com/opensearch-project/oui/assets/65143821/c15db0c1-fd19-48d9-a458-cab4642d459d

After

https://github.com/opensearch-project/oui/assets/65143821/6326c9d9-db29-45a0-87ef-fbcc2703195d

Misc

Also fix a typo in guide_version_selector.tsx.

Check List

  • [ ] New functionality includes testing.
  • [ ] New functionality has been documented.
  • [ ] All tests pass
    • [ ] yarn lint
    • [ ] yarn test-unit
  • [ ] Update CHANGELOG.md
  • [x] Commits are signed per the DCO using --signoff

willie-hung avatar Nov 21 '23 22:11 willie-hung

Hi @kgcreative, could you please assist in determining the best UX for this scenario? Thank you!

willie-hung avatar Nov 21 '23 22:11 willie-hung

This is a challenging one. When opening via mouse, we shouldn't have a focus selector, however, per WCAG accessibility standards, there is an expectation that when you open a control via keyboard interaction, that we move keyboard focus to the first item in the opened control. As such, if we can't differentiate between keyboard or mouse input, the existing behavior is the more correct one.

Additional context: https://www.w3.org/TR/UNDERSTANDING-WCAG20/navigation-mechanisms-focus-visible.html

kgcreative avatar Nov 22 '23 00:11 kgcreative

Thanks for sharing your insights, @kgcreative! Based on what you've described, would you suggest implementing a mechanism where if the element is opened via keyboard (for example, pressing the Tab key), we highlight the selector, but if not, we skip the highlighting?

willie-hung avatar Nov 22 '23 04:11 willie-hung

Thanks for sharing your insights, @kgcreative! Based on what you've described, would you suggest implementing a mechanism where if the element is opened via keyboard (for example, pressing the Tab key), we highlight the selector, but if not, we skip the highlighting?

This may be a larger issue. I would explore using :focus-visible instead of :focus, since that does use browser heuristics to determine whether an element should have a visible focus indicator or not.

cc: @BSFishy + @joshuarrrr

kgcreative avatar Nov 29 '23 22:11 kgcreative

I feel like this is the wrong way to go about this. I think that changing the default value for focus would be breaking for UX. Additionally, OuiContextMenuPanelDescriptor offers initialFocusedItemIndex, which I think would be a better way to implement this. Just set that value to whatever value is currently selected. That way we don't even need to differentiate if the panel was opened by keyboard or mouse

BSFishy avatar Dec 04 '23 17:12 BSFishy

Yeah, this needs to be a component level change, not changing the fous behavior in the implementation

kgcreative avatar Dec 04 '23 20:12 kgcreative

@willie-hung are you interested in taking this forward or would you rather have it closed?

AMoo-Miki avatar Jul 12 '24 18:07 AMoo-Miki

Hi @AMoo-Miki, I think it should be closed for now. However, if you decide to make changes at the component level, I would be happy to join the discussion and assist with the development.

willie-hung avatar Jul 12 '24 18:07 willie-hung

Closing as recommended.

AMoo-Miki avatar Sep 09 '24 16:09 AMoo-Miki