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

Border radius control: incorrect usage of Tooltip causes unexpected tab stop #68591

Open
2 of 6 tasks
afercia opened this issue Jan 10, 2025 · 3 comments · May be fixed by #68594
Open
2 of 6 tasks

Border radius control: incorrect usage of Tooltip causes unexpected tab stop #68591

afercia opened this issue Jan 10, 2025 · 3 comments · May be fixed by #68594
Assignees
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@afercia
Copy link
Contributor

afercia commented Jan 10, 2025

Description

Discovered while testing #68498

This is one more occurrence of incorrect usage of the Tooltip component. Cc @WordPress/gutenberg-components

The Ariakit-based Tooltip adds a tabindex=0 attribute to the DOM element it wraps. When the wrapped DOM element happens to be an element that is supposed to be focusable that't not a big deal. However, when the wrapped element is just a DIV element, it becomes a focusable non-interactive, non-labeled element. This isn't OK and among other things it causes an unexpected tab stop when using the keuboard.

<Tooltip text={ label } placement="top" key={ corner }>
<div className="components-border-radius-control__tooltip-wrapper">
<UnitControl
{ ...props }
aria-label={ label }
value={ [ parsedQuantity, computedUnit ].join(
''
) }
onChange={ createHandleOnChange( corner ) }
onUnitChange={ createHandleOnUnitChange(
corner
) }
size="__unstable-large"
/>
</div>
</Tooltip>

In this case, the element with CSS class components-border-radius-control__tooltip-wrapper gets a tabindex=0. As such, tabbing through the UI requires an additional, unexpected, Tab press on an element that isn't interactive just to make hte Tooltip appear.

Animated GIF:

Image

Step-by-step reproduction instructions

  • Select a Group block.
  • Go to the block settings panel > Styles > Radius setting and click the 'Unlink radii' icon button to switch the control to the UI that renders 4 input fields.
  • Use the Tab key to navigate through the four input fields.
  • Observe you have to Tab three times for each input:
    1. FIrst tab stop: the focusable DIV with tabindex=0
    2. Second tab stop: the actual input field
    3. Third tab stop: The 'Select unit' select element.

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@afercia afercia added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Type] Bug An existing feature does not function as intended labels Jan 10, 2025
@Rishit30G
Copy link
Contributor

Thanks for sharing the issue,
I could replicate the issue on my local
So as per my understanding if we remove the div and add the class to the UnitControl Component, we can get proper tab navigation

<Tooltip text={ label } placement="top" key={ corner }>
     <UnitControl
		{ ...props }
		aria-label={ label }
		value={ [ parsedQuantity, computedUnit ].join('') }
		onChange={ createHandleOnChange( corner ) }
		onUnitChange={ createHandleOnUnitChange( corner ) }
	         size="__unstable-large"
		className="components-border-radius-control__tooltip-wrapper"
	/>
</Tooltip>

Before:

Screen.Recording.2025-01-10.at.3.52.15.PM.mov

After:

Screen.Recording.2025-01-10.at.3.45.41.PM.mov

@yogeshbhutkar
Copy link
Contributor

yogeshbhutkar commented Jan 10, 2025

I think we can pass the classname to Tooltip component directly as Unit Control is indeed what is getting wrapped here.

Edit: Looks like the classname isn't used anywhere.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jan 10, 2025
@afercia
Copy link
Contributor Author

afercia commented Jan 10, 2025

I think this should be fixed by removing the Tooltip component, set the key to the wrapepr and change aria-label to label on the UnitControl.

This would make the input field labels visible. As such, some design adjustments may be neeed but input fields are really not supposed to have tooltips.

My guess is that the current, incorrect, implementation was only done to hide the labels and use tooltips for the input fields. That's not great for accessibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [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.

3 participants