-
Notifications
You must be signed in to change notification settings - Fork 101
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(ui-menu): screenreaders should read the correct number of menu items #1831
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 |
---|---|---|
|
@@ -82,11 +82,8 @@ class MenuItemGroup extends Component<MenuGroupProps, MenuGroupState> { | |
selected: this.selectedFromChildren(props) || props.defaultSelected! | ||
} | ||
} | ||
|
||
this._labelId = props.deterministicId!('MenuItemGroup') | ||
} | ||
|
||
private _labelId: string | ||
ref: Element | null = null | ||
|
||
handleRef = (el: Element | null) => { | ||
|
@@ -210,23 +207,18 @@ class MenuItemGroup extends Component<MenuGroupProps, MenuGroupState> { | |
++index | ||
const value = child.props.value || index | ||
|
||
return ( | ||
<li role="none"> | ||
{' '} | ||
{safeCloneElement(child, { | ||
tabIndex: isTabbable && index === 0 ? 0 : -1, | ||
controls, | ||
value, | ||
children: child.props.children, | ||
type: allowMultiple ? 'checkbox' : 'radio', | ||
ref: this.props.itemRef, | ||
disabled: disabled || child.props.disabled, | ||
selected: this.selected.indexOf(value) > -1, | ||
onSelect: this.handleSelect, | ||
onMouseOver | ||
})}{' '} | ||
</li> | ||
) | ||
return safeCloneElement(child, { | ||
tabIndex: isTabbable && index === 0 ? 0 : -1, | ||
controls, | ||
value, | ||
children: child.props.children, | ||
type: allowMultiple ? 'checkbox' : 'radio', | ||
ref: this.props.itemRef, | ||
disabled: disabled || child.props.disabled, | ||
selected: this.selected.indexOf(value) > -1, | ||
onSelect: this.handleSelect, | ||
onMouseOver | ||
}) | ||
} else { | ||
return child | ||
} | ||
|
@@ -239,18 +231,15 @@ class MenuItemGroup extends Component<MenuGroupProps, MenuGroupState> { | |
<span | ||
{...props} | ||
css={this.props.styles?.menuItemGroup} | ||
role="presentation" | ||
ref={this.handleRef} | ||
> | ||
<span id={this._labelId}>{this.renderLabel()}</span> | ||
<ul | ||
role="menu" | ||
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. This should be used for submenus and menus, not for groups per specification https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/menu_role |
||
{this.renderLabel()} | ||
<div | ||
css={this.props.styles?.items} | ||
aria-disabled={this.props.disabled ? 'true' : undefined} | ||
aria-labelledby={this._labelId} | ||
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. there is no need for |
||
> | ||
{this.renderChildren()} | ||
</ul> | ||
</div> | ||
</span> | ||
) | ||
} | ||
|
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.
A Menu having a
button
not amenuitem
was driving NVDA crazy. NVDA really seems to be the most strict of them all