-
Notifications
You must be signed in to change notification settings - Fork 327
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,8 @@ export interface MenuItemProps extends VibeComponentProps { | |
splitMenuItem?: boolean; | ||
"aria-label"?: AriaAttributes["aria-label"]; | ||
submenuPosition?: SubmenuPosition; | ||
tooltipId?: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of adding an id, can be implemented using the id from |
||
shouldShowTooltip?: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
|
||
export interface MenuItemTitleComponentProps extends Omit<MenuItemProps, "title"> { | ||
|
@@ -121,6 +123,7 @@ const MenuItem: VibeComponent<MenuItemProps | MenuItemTitleComponentProps> & { | |
content={shouldShowTooltip ? finalTooltipContent : null} | ||
position={tooltipPosition} | ||
showDelay={tooltipShowDelay} | ||
childId={baseMenuProps.id} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tooltip has an id prop do we need to add a |
||
{...tooltipProps} | ||
> | ||
<BaseMenuItem | ||
|
@@ -130,6 +133,8 @@ const MenuItem: VibeComponent<MenuItemProps | MenuItemTitleComponentProps> & { | |
className={className} | ||
disabled={disabled} | ||
selected={selected} | ||
tooltipId={tooltipProps?.id} | ||
shouldShowTooltip={!!shouldShowTooltip} | ||
Comment on lines
+136
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to simplify it it might be clearer to add |
||
{...baseMenuProps} | ||
> | ||
{Boolean(icon) && ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ interface TooltipBaseProps extends VibeComponentProps { | |
* how much delay should the Dialog wait until it should trigger the show in MS | ||
*/ | ||
showDelay?: number; | ||
childId?: string; | ||
disableDialogSlide?: boolean; | ||
animationType?: DialogAnimationType; | ||
withoutDialog?: boolean; | ||
|
@@ -178,7 +179,7 @@ export default class Tooltip extends PureComponent<TooltipProps> { | |
} | ||
|
||
renderTooltipContent() { | ||
const { theme, content, className, style, maxWidth, title, image, icon } = this.props; | ||
const { theme, content, className, style, maxWidth, title, image, icon, id, childId } = this.props; | ||
if (!content) { | ||
// don't render empty tooltip | ||
return null; | ||
|
@@ -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)}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would the id be enough? why need to add |
||
{title && ( | ||
<Flex gap="xs"> | ||
{icon && <Icon iconSize="20" icon={icon} />} | ||
|
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.
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.