Skip to content
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

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

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

Conversation

willie-hung
Copy link
Contributor

@willie-hung willie-hung commented Nov 21, 2023

Description

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

Issues Resolved

Fixes #1163

Demo

Before

before.mov

After

After.mov

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
  • Commits are signed per the DCO using --signoff

Signed-off-by: Willie Hung <willie880201044@gmail.com>
@willie-hung
Copy link
Contributor Author

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

Signed-off-by: Willie Hung <willie880201044@gmail.com>
@kgcreative
Copy link
Member

kgcreative commented Nov 22, 2023

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

@willie-hung
Copy link
Contributor Author

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?

@kgcreative
Copy link
Member

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

@BSFishy
Copy link
Contributor

BSFishy commented Dec 4, 2023

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 BSFishy added the OSCI label Dec 4, 2023
@kgcreative
Copy link
Member

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

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.

[BUG] Theme selector incorrectly focus on first item after selection
3 participants