Skip to content

Commit

Permalink
feat: only use aria-selected with these roles: option, tab, `me…
Browse files Browse the repository at this point in the history
…nuitemradio`, `treeitem`, `gridcell`, `row`, `rowheader`, and `columnheader`
  • Loading branch information
cheton committed Oct 9, 2023
1 parent 55142fa commit 5e546c8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/react/src/button/Button.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ariaAttr } from '@tonic-ui/utils';
import { ariaAttr, dataAttr } from '@tonic-ui/utils';
import React, { forwardRef } from 'react';
import ButtonBase from './ButtonBase';
import { useButtonStyle } from './styles';
Expand Down Expand Up @@ -39,17 +39,17 @@ const Button = forwardRef((

const attributes = {
'aria-disabled': ariaAttr(disabled),
'aria-selected': ariaAttr(selected),

// Only use `aria-selected` with these roles: `option`, `tab`, `menuitemradio`, `treeitem`, `gridcell`, `row`, `rowheader`, and `columnheader`.
'data-selected': dataAttr(selected),

type: 'button',

// Disable the button if "disabled" is true
disabled,

/**
* For button in the disabled state, just keep "pointer-events" and "tabIndex" as is.
* For button in the selected state, set both "pointer-events: none" and "tabIndex: -1" to prevent the button receiving focus through sequential keyboard navigation.
*/
// For button in the disabled state, just keep "pointer-events" and "tabIndex" as is.
// For button in the selected state, set both "pointer-events: none" and "tabIndex: -1" to prevent the button receiving focus through sequential keyboard navigation.
tabIndex: selected ? -1 : undefined,
};

Expand Down

0 comments on commit 5e546c8

Please sign in to comment.