Fix disabled state on AccessibleButton not being exposed via ARIA

pull/21833/head
Michael Telatynski 2021-08-06 12:28:20 +01:00
parent d285a45da5
commit 3895345250
1 changed files with 4 additions and 2 deletions

View File

@ -67,7 +67,9 @@ export default function AccessibleButton({
...restProps ...restProps
}: IProps) { }: IProps) {
const newProps: IAccessibleButtonProps = restProps; const newProps: IAccessibleButtonProps = restProps;
if (!disabled) { if (disabled) {
newProps["aria-disabled"] = true;
} else {
newProps.onClick = onClick; newProps.onClick = onClick;
// We need to consume enter onKeyDown and space onKeyUp // We need to consume enter onKeyDown and space onKeyUp
// otherwise we are risking also activating other keyboard focusable elements // otherwise we are risking also activating other keyboard focusable elements
@ -118,7 +120,7 @@ export default function AccessibleButton({
); );
// React.createElement expects InputHTMLAttributes // React.createElement expects InputHTMLAttributes
return React.createElement(element, restProps, children); return React.createElement(element, newProps, children);
} }
AccessibleButton.defaultProps = { AccessibleButton.defaultProps = {