A11y fix role-has-required-aria-props (#7455)
* remove jsx a11y direct use in eslintrc Signed-off-by: Kerry Archibald <kerrya@element.io> * remove debug Signed-off-by: Kerry Archibald <kerrya@element.io> * split aria-selected out from restProps in Autocomplete Signed-off-by: Kerry Archibald <kerrya@element.io> * update Dropdown to aria 1.1 aria-owns -> aria-controls Signed-off-by: Kerry Archibald <kerrya@element.io> * unignore jsx-a11y/role-has-required-aria-props rule Signed-off-by: Kerry Archibald <kerrya@element.io> * remove debug Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
parent
846fbfa2a0
commit
aaf14aacd2
3 changed files with 24 additions and 5 deletions
|
@ -56,7 +56,6 @@ module.exports = {
|
||||||
"jsx-a11y/no-noninteractive-element-to-interactive-role": "off",
|
"jsx-a11y/no-noninteractive-element-to-interactive-role": "off",
|
||||||
"jsx-a11y/no-noninteractive-tabindex": "off",
|
"jsx-a11y/no-noninteractive-tabindex": "off",
|
||||||
"jsx-a11y/no-static-element-interactions": "off",
|
"jsx-a11y/no-static-element-interactions": "off",
|
||||||
"jsx-a11y/role-has-required-aria-props": "off",
|
|
||||||
"jsx-a11y/role-supports-aria-props": "off",
|
"jsx-a11y/role-supports-aria-props": "off",
|
||||||
"jsx-a11y/tabindex-no-positive": "off",
|
"jsx-a11y/tabindex-no-positive": "off",
|
||||||
},
|
},
|
||||||
|
|
|
@ -31,11 +31,19 @@ interface ITextualCompletionProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TextualCompletion = forwardRef<ITextualCompletionProps, any>((props, ref) => {
|
export const TextualCompletion = forwardRef<ITextualCompletionProps, any>((props, ref) => {
|
||||||
const { title, subtitle, description, className, ...restProps } = props;
|
const {
|
||||||
|
title,
|
||||||
|
subtitle,
|
||||||
|
description,
|
||||||
|
className,
|
||||||
|
'aria-selected': ariaSelectedAttribute,
|
||||||
|
...restProps
|
||||||
|
} = props;
|
||||||
return (
|
return (
|
||||||
<div {...restProps}
|
<div {...restProps}
|
||||||
className={classNames('mx_Autocomplete_Completion_block', className)}
|
className={classNames('mx_Autocomplete_Completion_block', className)}
|
||||||
role="option"
|
role="option"
|
||||||
|
aria-selected={ariaSelectedAttribute}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
>
|
>
|
||||||
<span className="mx_Autocomplete_Completion_title">{ title }</span>
|
<span className="mx_Autocomplete_Completion_title">{ title }</span>
|
||||||
|
@ -50,11 +58,20 @@ interface IPillCompletionProps extends ITextualCompletionProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PillCompletion = forwardRef<IPillCompletionProps, any>((props, ref) => {
|
export const PillCompletion = forwardRef<IPillCompletionProps, any>((props, ref) => {
|
||||||
const { title, subtitle, description, className, children, ...restProps } = props;
|
const {
|
||||||
|
title,
|
||||||
|
subtitle,
|
||||||
|
description,
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
'aria-selected': ariaSelectedAttribute,
|
||||||
|
...restProps
|
||||||
|
} = props;
|
||||||
return (
|
return (
|
||||||
<div {...restProps}
|
<div {...restProps}
|
||||||
className={classNames('mx_Autocomplete_Completion_pill', className)}
|
className={classNames('mx_Autocomplete_Completion_pill', className)}
|
||||||
role="option"
|
role="option"
|
||||||
|
aria-selected={ariaSelectedAttribute}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
>
|
>
|
||||||
{ children }
|
{ children }
|
||||||
|
|
|
@ -313,7 +313,7 @@ export default class Dropdown extends React.Component<IProps, IState> {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
if (options.length === 0) {
|
if (options.length === 0) {
|
||||||
return [<div key="0" className="mx_Dropdown_option" role="option">
|
return [<div key="0" className="mx_Dropdown_option" role="option" aria-selected={false}>
|
||||||
{ _t("No results") }
|
{ _t("No results") }
|
||||||
</div>];
|
</div>];
|
||||||
}
|
}
|
||||||
|
@ -331,6 +331,7 @@ export default class Dropdown extends React.Component<IProps, IState> {
|
||||||
if (this.props.searchEnabled) {
|
if (this.props.searchEnabled) {
|
||||||
currentValue = (
|
currentValue = (
|
||||||
<input
|
<input
|
||||||
|
id={`${this.props.id}_input`}
|
||||||
type="text"
|
type="text"
|
||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
className="mx_Dropdown_option"
|
className="mx_Dropdown_option"
|
||||||
|
@ -339,7 +340,8 @@ export default class Dropdown extends React.Component<IProps, IState> {
|
||||||
role="combobox"
|
role="combobox"
|
||||||
aria-autocomplete="list"
|
aria-autocomplete="list"
|
||||||
aria-activedescendant={`${this.props.id}__${this.state.highlightedOption}`}
|
aria-activedescendant={`${this.props.id}__${this.state.highlightedOption}`}
|
||||||
aria-owns={`${this.props.id}_listbox`}
|
aria-expanded={this.state.expanded}
|
||||||
|
aria-controls={`${this.props.id}_listbox`}
|
||||||
aria-disabled={this.props.disabled}
|
aria-disabled={this.props.disabled}
|
||||||
aria-label={this.props.label}
|
aria-label={this.props.label}
|
||||||
onKeyDown={this.onKeyDown}
|
onKeyDown={this.onKeyDown}
|
||||||
|
@ -382,6 +384,7 @@ export default class Dropdown extends React.Component<IProps, IState> {
|
||||||
inputRef={this.buttonRef}
|
inputRef={this.buttonRef}
|
||||||
aria-label={this.props.label}
|
aria-label={this.props.label}
|
||||||
aria-describedby={`${this.props.id}_value`}
|
aria-describedby={`${this.props.id}_value`}
|
||||||
|
aria-owns={`${this.props.id}_input`}
|
||||||
onKeyDown={this.onKeyDown}
|
onKeyDown={this.onKeyDown}
|
||||||
>
|
>
|
||||||
{ currentValue }
|
{ currentValue }
|
||||||
|
|
Loading…
Reference in a new issue