Skip to content

Commit

Permalink
fix: correct button management for disabled state
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Feb 14, 2022
1 parent 36f4540 commit 463682e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .size.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
"name": "dist/es2015/index.js",
"passed": true,
"size": 2536
"size": 2558
}
]
5 changes: 4 additions & 1 deletion src/utils/is.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ export const getDataset = (node: Element): HTMLElement['dataset'] | undefined =>

export const isHTMLButtonElement = (node: Element): node is HTMLInputElement => node.tagName === 'BUTTON';
export const isHTMLInputElement = (node: Element): node is HTMLInputElement => node.tagName === 'INPUT';

export const isRadioElement = (node: Element): node is HTMLInputElement =>
isHTMLInputElement(node) && node.type === 'radio';

export const notHiddenInput = (node: Element): boolean =>
!((isHTMLInputElement(node) || isHTMLInputElement(node)) && (node.type === 'hidden' || node.disabled));
!((isHTMLInputElement(node) || isHTMLButtonElement(node)) && (node.type === 'hidden' || node.disabled)) &&
// @ts-ignore
!node.ariaDisabled;
export const isGuard = (node: Element | undefined): boolean => Boolean(node && getDataset(node)?.focusGuard);
export const isNotAGuard = (node: Element | undefined): boolean => !isGuard(node);

Expand Down
2 changes: 2 additions & 0 deletions src/utils/tabbables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const tabbables = [
'select:enabled',
'textarea:enabled',
'input:enabled',
// elements with explicit roles will also use explicit tabindex
// '[role="button"]',

'a[href]',
'area[href]',
Expand Down

0 comments on commit 463682e

Please sign in to comment.