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

Tooltip examples are not accessible on dropdown items #7524

Merged

Conversation

bartoval
Copy link
Member

@bartoval bartoval commented Jun 7, 2022

What: Closes #6109

it seems to work also adding the aria-labelledby prop, but the screen reader announces the tooltip before the item.

I tested the voice using the screen reader chrome plugin

@bartoval bartoval requested a review from thatblindgeye June 7, 2022 16:34
@patternfly-build
Copy link
Contributor

patternfly-build commented Jun 7, 2022

Copy link
Contributor

@nicolethoen nicolethoen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My expectation is that the tooltip would display on VO focus just like it would on keyboard focus or mouse hover.

Here is a gif of what happens when I use a mouse to hover over an enabled dropdown item with a tooltip and a disabled item with a tooltip:
using mouse

In this second recording, you'll see that the VO does not trigger the tooltip in either case until I try to click on it. When I click on the disabled dropdown item, it does finally reveal the tooltip and read it (so that's an improvement!) but I cannot trigger the tooltip on the enabled dropdown item because that also selects the item and closes the dropdown
using VO

@thatblindgeye
Copy link
Contributor

thatblindgeye commented Jun 7, 2022

My expectation is that the tooltip would display on VO focus just like it would on keyboard focus or mouse hover.

@nicolethoen I'm noticing this behavior as well. It looks like VO is placing focus on the li element rather than the button within that list item. If you go into the list item with VO + Shift + down arrow, focus should go onto that button and trigger the tooltip. The Tab component had a similar issue back when I had to resolve an issue similar to this. It looks like the InternalDropdownItem component has logic setup similar to my fix for Tab, but one difference is the li element within the Tab component has role="presentation" whereas the dropdown items have `role="menuitem".

My previous comment about making this change here most likely wouldn't work since we'd lose the semantics of the items being menu items.

@bartoval bartoval self-assigned this Jun 8, 2022
@bartoval
Copy link
Member Author

bartoval commented Jun 8, 2022

I updated the code. Now everything should work as expected.
However, this solution seems more of a 'workaround'.

Another solution could be

  • set <li> with the role="presentation"
  • pass to the button or link a prop role='menuitem'

This solution should work well and it is clean.
However, the screen reader will no longer announce the world 'group'.
So instead:
Link, menu item, group, 1 of 7
the screen reader will announce
Link, menu item,1 of 7

Honestly, for our menu items, I don't see the utility of announcing group

Another small difference:
For item disabled the screen reader announces a new word: dimmed:
Disable menu item, dimmed, menu item, 4 of 7)

WDYT
@thatblindgeye @nicolethoen

@bartoval bartoval requested a review from nicolethoen June 8, 2022 17:15
@thatblindgeye
Copy link
Contributor

Going off of Valerio's comment about the utility of having "group" announced on these menu items, it does seem odd that we end up indicating to a user that they are on a menu item group that contains a single element.

Some links that lean more towards Valerio's other solution of moving the role="menuitem" to the button/link inside the li (which would then be given role="presentation"):

Based on these links I think I might be leaning more towards the alternative solution mentioned.

@nicolethoen
Copy link
Contributor

nicolethoen commented Jun 9, 2022

I agree with @thatblindgeye, I think.

However, I'm noticing that the Menu component uses <li role="none"> instead of presentation.
It also adds a menu role to the <ul>.

So I think it's more in line with other solutions to do the following (if it all works with tooltips)

  • set <ul> with the role="menu"
  • set <li> with the role="none"
  • pass to the button or link a prop role='menuitem'

Other notes:

  • the word dimmed is standard for disabled elements, so that's good news
  • We need to be sure the tooltip can be triggered with the screen reader on disabled AND enabled dropdown items

@tlabaj tlabaj added the A11y label Jun 9, 2022
@tlabaj tlabaj requested a review from jessiehuff June 9, 2022 21:34
@bartoval bartoval force-pushed the tooltip_example_dropdown_no_accessible branch from d43053d to 09b61db Compare June 10, 2022 06:18
@bartoval bartoval force-pushed the tooltip_example_dropdown_no_accessible branch from 09b61db to 97373cd Compare June 10, 2022 06:39
@bartoval
Copy link
Member Author

role="menu" was already set in <ul>, so no need to add it.

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! The tooltip triggers via mouse, keyboard, and with VO navigation for me, and the tooltip gets announced when triggered as well. Had a nitpick/question below, but otherwise awesome job on this 💪🏼

@@ -211,7 +211,7 @@ export class InternalDropdownItem extends React.Component<InternalDropdownItemPr
...(styleChildren && {
className: css(element.props.className, classes)
}),
...(this.props.role !== 'separator' && { ref: this.componentRef })
...(this.props.role !== 'separator' && { role } && { ref: this.componentRef })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: could this also be written as ...(this.props.role !== 'separator' && { role, ref: this.componentRef })?

@bartoval bartoval requested a review from thatblindgeye June 14, 2022 12:37
Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks and sounds as I'd expect! Awesome work on this

Copy link
Contributor

@kmcfaul kmcfaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Copy link
Contributor

@jessiehuff jessiehuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an improvement! I hear everything announced as I would expected in VO. Out of curiosity, I tested in NVDA and JAWS as well, and I noticed that it didn't work in either of those screen readers. Since this still moves things forward, I'm wondering if it makes sense to approve this but open another issue for JAWS and NVDA? Those are pretty big screen readers that I wouldn't want to completely neglect.

@tlabaj tlabaj merged commit f302f29 into patternfly:main Jun 15, 2022
@patternfly-build
Copy link
Contributor

Your changes have been released in:

Thanks for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tooltip examples are not accessible on dropdown items.
7 participants