Skip to content

Options in the CircularOptionPicker may be not operable with the keyboard #65283

@afercia

Description

@afercia

Description

Working on #65124 surfaced an edge case where the buttons in the color picker may end up in a state where they're not focusable because they all have a tabindex="-1" attribute.

I'm not sure what is the root cause but I see some recent work on the CircularOptionPicker and the underlying Composite components in #64833

It appears to me the UI may end up in a state where the value of the circular option picker option activeId value doesn't match any HTML id attribute in the UI. As such, none of the color buttons is considered 'active'. Worth reminding the 'actice' button is expected to be the only button that is focusable with the Tab key, while navigation to the other buttons works via arrow keys.

Cc @WordPress/gutenberg-components

Three prerequisites to reproduce the bug:

  • Seems the bug can be reproduced only with themes that display more than one color palette in the panel:
    • Twenty Twenty-Three: Theme and Default palettes - can reproduce
    • Twenty Twenty-Four: Theme palette - cannot reproduce
    • Twenty Twenty-Five: Theme and Default palettes - can reproduce
  • Switch to the branch from Global styles menu: Avoid visible labels and accessible names mismatch #65124 to reproduce.
  • Go to the WP admin > Gutenberg > Experiments and enable the 'Color randomizer' experiment.

Aniamted GIF to illustrate; Notice that after randomizing the colors, tabbing through the UI entirely skipcs the color picker buttons:

circular color picker options not focusable

Step-by-step reproduction instructions

  • Set the prerequisites as described above.
  • Test with Twenty Twenty-Four.
  • Go to Site Editor > Styles > Colors > Edit palette.
  • Tab through the UI and observe the color picker buttons are operable with the keyboard.
  • Move focus to the Randomize colors button and press Enter.
  • At this point, the color buttons in the picker re-render. They get new IDs.
  • Tab backwards and forwards through the UI and observe that the color picker buttons are still operable with the keyboard.
  • Test with Twenty Twenty-Three or Twenty Twenty-Five.
  • Repeat the steps above.
  • On the last step, observe that now none of the color picker buttons is operable with the keyboard.

Inspecting the source:

  • All the buttons have a tabindex="-1" attribute.
  • Expected: the 'active' button to be focusable (not sure whether tabindex should be removed or be tabindex="0").
  • In my testing, dumping the value of activeId may return a value that doesn't match any ID attribute in the DOM. for example:
    • The activeId value is components-circular-option-picker-3-75.
    • None of the IDs of the 8 buttons in the screenshot below matches activeId e.g.:
components-circular-option-picker-3-43
components-circular-option-picker-3-45
components-circular-option-picker-3-83
components-circular-option-picker-3-85
components-circular-option-picker-3-87
components-circular-option-picker-3-53
components-circular-option-picker-3-89
components-circular-option-picker-3-57

Screenshot 2024-09-12 at 14 44 41

Worth also noting that the ID values in the HTML are not consecutive. I would expect to be numbers progressively incremented by 1. Instead, they appear to be pretty inconsistent, which makes me think to some timing issue and the ID being genereated randomly across the multiple instances of the color picker.

Screenshots, screen recording, code snippet

No response

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

Metadata

Metadata

Assignees

Labels

[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).[Package] Components/packages/components[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions