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

fix: menu item a11y for disable items #2628

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

doronbrikman
Copy link
Contributor

@doronbrikman doronbrikman commented Dec 5, 2024

https://monday.monday.com/boards/5751390280/pulses/5751647586

Resolves #
It will let screen readers reach disabled items and be aware of the disable reason

@doronbrikman doronbrikman requested a review from a team as a code owner December 5, 2024 10:18
@doronbrikman doronbrikman changed the title menu item a11y for disable items fix: menu item a11y for disable items Dec 5, 2024
Copy link
Contributor

@rivka-ungar rivka-ungar left a comment

Choose a reason for hiding this comment

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

Thanks! added some questions. Also would be great if you can add some tests to verify the new behavior.

@@ -2,7 +2,7 @@ import { ReactElement } from "react";
import { MenuChild } from "../MenuConstants";

export function isMenuChildSelectable(child: MenuChild): boolean {
return !!child.type.isSelectable && !child.props.disabled;
return !!child.type.isSelectable;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we only want it to be selectable if it is disabled and has a tooltip (but should not be selectable when it is disabled without a tooltip), the check for disabled should stay, and there should be an additional check if has tooltip.

@@ -56,6 +56,8 @@ export interface MenuItemProps extends VibeComponentProps {
splitMenuItem?: boolean;
"aria-label"?: AriaAttributes["aria-label"];
submenuPosition?: SubmenuPosition;
tooltipId?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding an id, can be implemented using the id from tooltipProps

@@ -56,6 +56,8 @@ export interface MenuItemProps extends VibeComponentProps {
splitMenuItem?: boolean;
"aria-label"?: AriaAttributes["aria-label"];
submenuPosition?: SubmenuPosition;
tooltipId?: string;
shouldShowTooltip?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this prop? there is already logic in the component for this here.

Comment on lines +136 to +137
tooltipId={tooltipProps?.id}
shouldShowTooltip={!!shouldShowTooltip}
Copy link
Contributor

Choose a reason for hiding this comment

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

In order to simplify it it might be clearer to add aria-disabled and aria-describedby props instead of the tooltip specific props so that the logic can be done here.

@@ -121,6 +123,7 @@ const MenuItem: VibeComponent<MenuItemProps | MenuItemTitleComponentProps> & {
content={shouldShowTooltip ? finalTooltipContent : null}
position={tooltipPosition}
showDelay={tooltipShowDelay}
childId={baseMenuProps.id}
Copy link
Contributor

Choose a reason for hiding this comment

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

Tooltip has an id prop do we need to add a childId?

@@ -205,7 +206,7 @@ export default class Tooltip extends PureComponent<TooltipProps> {
className={cx(styles.tooltip, getStyle(styles, camelCase(theme)), className)}
>
{image && <img className={styles.image} src={image} alt="" />}
<div className={cx(styles.content)}>
<div id={id || `${childId}-tooltip`} className={cx(styles.content)}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Would the id be enough? why need to add childId?

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

Successfully merging this pull request may close these issues.

2 participants