-
Notifications
You must be signed in to change notification settings - Fork 152
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
Tooltip accessibility improvements #4639
base: master
Are you sure you want to change the base?
Conversation
Deploying orbit with
|
Latest commit: |
0572b7c
|
Status: | ✅ Deploy successful! |
Preview URL: | https://586102f4.orbit.pages.dev |
Branch Preview URL: | https://domi-tooltip.orbit.pages.dev |
Storybook staging is available at https://kiwicom-orbit-domi-tooltip.surge.sh Playroom staging is available at https://kiwicom-orbit-domi-tooltip.surge.sh/playroom |
Size Change: +60 B (+0.01%) Total Size: 463 kB
ℹ️ View Unchanged
|
I was taking look at how we could refactor Tooltip to not wrap the trigger element with the button role and it seems that other component libraries are using e.g. cloning the element or compound components, but this is rather complicated task so I crated task to tackle this in the future as advised https://kiwicom.atlassian.net/browse/FEPLT-2352 I was also taking look at the "ARIA commands must have an accessible name" violation in Radio and Checkbox components but I would say those can be fixed in those components directly without changes needed to Tooltip component. |
@@ -16,7 +16,7 @@ const TooltipWrapper = React.forwardRef< | |||
className={cx( | |||
"orbit-tooltip-wrapper", | |||
"max-w-full cursor-auto", | |||
"focus:outline-none active:outline-none [&_:disabled]:pointer-events-none", | |||
"focus:outline-offset-1 active:outline-offset-1 [&_:disabled]:pointer-events-none", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we adjust the height of this wrapper to be h-fit-content
I believe it works well 🤔 can you confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the whole tooltip could be revamped. But not now. For now, I think we can accept the double focus 😕 unless you can think of something else, I'd move forward with the current solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DSil How about setting outline-none for those two classes inside Checkbox and Radio?
"focus:outline-offset-1 active:outline-offset-1 [&_:disabled]:pointer-events-none", | |
"focus:outline-offset-1 active:outline-offset-1 [&_:disabled]:pointer-events-none", | |
"[&:has(.orbit-checkbox-icon-container,.orbit-radio-icon-container)]:focus:outline-none [&:has(.orbit-checkbox-icon-container,.orbit-radio-icon-container)]:active:outline-none", |
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only fixes a visual problem, right? We still can hit the tab key twice, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. That would require some refactoring in those two components or more refactoring of Tooltip Wrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I am ok with just fixing the visual issue, yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tooltip wrapper is having aria-describedby
with the id of the content. That is weird because the wrapper is always rendered but the tooltip is not. So it says it is described by something not on the DOM. Can we somehow conditionally add it?
@@ -16,7 +16,7 @@ const TooltipWrapper = React.forwardRef< | |||
className={cx( | |||
"orbit-tooltip-wrapper", | |||
"max-w-full cursor-auto", | |||
"focus:outline-none active:outline-none [&_:disabled]:pointer-events-none", | |||
"focus:outline-offset-1 active:outline-offset-1 [&_:disabled]:pointer-events-none", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we adjust the height of this wrapper to be h-fit-content
I believe it works well 🤔 can you confirm?
ba5cfe1
to
da99ef6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key Issues
The removal of aria-describedby
when the tooltip is hidden creates an accessibility issue, as screen readers need this attribute to understand the relationship between elements and their descriptions, ensuring users are aware of additional information.
@@ -115,7 +115,7 @@ const TooltipPrimitive = ({ | |||
onFocus={handleIn} | |||
onBlur={handleOut} | |||
ref={setReferenceElement} | |||
aria-describedby={enabled ? id || tooltipId : undefined} | |||
aria-describedby={shown ? id || tooltipId : undefined} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Possible Bug
Changing aria-describedby
to only be present when the tooltip is shown creates an accessibility issue. Screen readers need to know about the relationship between the trigger element and its description even when the tooltip is hidden. This ensures users can discover the presence of additional information before interacting with the element.
aria-describedby={shown ? id || tooltipId : undefined} | |
aria-describedby={enabled ? id || tooltipId : undefined} |
da99ef6
to
0572b7c
Compare
LLM Analysis of PR ChangesPull Request Feedback: Tooltip accessibility improvements (/pull/4639)Thank you for submitting this pull request to improve the accessibility of the Orbit component library! Here's an analysis of the changes based on the provided diff. 1. Summary of the changes: This pull request encompasses a wide range of accessibility improvements across the Orbit component library, going beyond just Tooltip. The key changes can be summarized as follows:
2. Potential issues or bugs you notice:
3. Suggestions for improvements:
4. Any security concerns:
5. Code quality observations:
Overall Feedback: This is a significant and valuable pull request that demonstrably improves the accessibility of the Orbit component library. The changes show a strong commitment to making the library more inclusive. However, the introduction of breaking changes requires careful consideration of the migration process for users. Addressing the suggestions above, particularly regarding codemods (or migration alternatives), tooltip Thank you for your hard work on these important accessibility improvements! |
Added focus indicator as a visible focus indicator is a requirement for all focusable elements and removing it is a violation of Success Criterion (SC) 2.4.7: Focus Visible (Level A), this includes tooltip trigger elements.
Also fixed stories (e.g. removed links from tooltips as tooltip content is not focusable) and enhanced Accessibility tab.
Closes https://kiwicom.atlassian.net/browse/FEPLT-2247
✨
Description by Callstackai
This PR improves tooltip accessibility by adding a focus indicator and ensuring that tooltip trigger elements are non-interactive components. It also removes links from tooltips and enhances the Accessibility tab.
Diagrams of code changes
Files Changed
Button
component to useasComponent='div'
for accessibility.Text
instead ofTextLink
for accessibility.aria-describedby
to useshown
instead ofenabled
.asComponent='div'
for accessibility.aria-describedby
to useshown
instead ofenabled
.This PR includes files in programming languages that we currently do not support. We have not reviewed files with the extensions
.mdx
. See list of supported languages.