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

Tabbing to Font size ToggleGroupControl applies a font size #62981

Closed
jeryj opened this issue Jun 28, 2024 · 7 comments · Fixed by #65892
Closed

Tabbing to Font size ToggleGroupControl applies a font size #62981

jeryj opened this issue Jun 28, 2024 · 7 comments · Fixed by #65892
Assignees
Labels
[Feature] UI Components Impacts or related to the UI component system [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Priority] High Used to indicate top priority items that need quick attention [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@jeryj
Copy link
Contributor

jeryj commented Jun 28, 2024

Description

When using a keyboard, you can't tab past the Typography Size in the Block Settings Sidebar without also applying a font size. There's no way to get past the field and also remain at the default style (no font size option).

Step-by-step reproduction instructions

  • Select a paragraph without any font sizes applied
  • Tab to the block settings sidebar
  • Continue tabbing past the font size selector in the Typography panel
  • The first font size option will be applied when you tab to the font size toggle group panel
  • Tab past the field, and the option will still be applied

Screenshots, screen recording, code snippet

Screen.Recording.2024-06-28.at.9.44.42.AM.mov

Video shows the cursor on a paragraph in the post editor. Tab keypresses move focus to the Block settings sidebar for the paragraph. There is no option selected for the Typography Font Size. When the tab key moves focus to the font size selector, the first option (small) is selected. Tab key is pressed again to move past the field and the small option is still selected, even though it was never intentionally acted on (enter or space keypress).

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@jeryj jeryj added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Feature] UI Components Impacts or related to the UI component system labels Jun 28, 2024
@t-hamano t-hamano added the [Package] Components /packages/components label Jun 29, 2024
@Mamaduka
Copy link
Member

I also noticed this issue a couple of times last week.

@mirka
Copy link
Member

mirka commented Sep 13, 2024

Confirming that this is an issue with the ToggleGroupControl itself, where focusing the component will forcibly select the first option. This should be fixed, especially because semantically this is a radio group and radio groups shouldn't work that way.

There's also a design aspect to this that needs to be resolved (discussed in #64439), because the current design only allows for a focus ring on the entire component and not a single option. But I think it would make sense to at least address the functionality part of this bug even if the design is not ready yet.

@Mamaduka
Copy link
Member

Confirming that this is an issue with the ToggleGroupControl itself, where focusing the component will forcibly select the first option.

@mirka, is this by "design" or just a bug in the component?

@mirka
Copy link
Member

mirka commented Sep 13, 2024

is this by "design" or just a bug in the component?

Definitely a bug!

@Mamaduka
Copy link
Member

Mamaduka commented Sep 14, 2024

It looks like the behavior is coming from this line introduced in #50278.

cc @ciampo

@ciampo
Copy link
Contributor

ciampo commented Sep 16, 2024

Thank you for the ping and report! I'll look into it and report back

@ciampo
Copy link
Contributor

ciampo commented Sep 18, 2024

I took a look, here are some considerations:

Currently, option items become selected when focused (ie. clicking them, pressing arrow keys). In that sense, we haven't yet distinguished in code between "this option item received focus because the user tabbed to the component" and "this option item received focus because the user moved the selection between options". We also currently lack the visual cues to show a "focussed but not selected" option item.

We have recently started discussing updates to style and behaviour of ToggleGroupControl in #64439, and I think we're close to reaching a consensus. If we were to implement a solution like the one discussed in #64439 (comment) and following, it feels like it would inherently fix this issue too (thanks to the individual focus styles, different from selected styles). An item could receive focus, but wouldn't be automatically selected. Only when the user explicitly presses arrow keys, (or clicks / pressed the enter key) a new option item is made (assuming that the item is not disabled).

cc @jameskoster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] UI Components Impacts or related to the UI component system [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Priority] High Used to indicate top priority items that need quick attention [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants