Skip to content

Commit 2827687

Browse files
committed
Properly handle buttons with aria-disabled and tabindex="-1" in focus helpers
Fixes #7728
1 parent cb24dbb commit 2827687

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.changeset/gentle-cobras-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Updates the focus helper functions to no longer treat buttons with `aria-disabled="disabled"` and `tabindex="-1" (but no`disabled` attribute) as focusable.

polaris-react/src/utilities/focus.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export type MouseUpBlurHandler = (
66
) => void;
77

88
const FOCUSABLE_SELECTOR =
9-
'a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]';
9+
'a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled):not([tabindex="-1"]),*[tabindex]';
1010
const KEYBOARD_FOCUSABLE_SELECTORS =
11-
'a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]:not([tabindex="-1"])';
11+
'a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled):not([tabindex="-1"]),*[tabindex]:not([tabindex="-1"])';
1212
const MENUITEM_FOCUSABLE_SELECTORS =
1313
'a[role="menuitem"],frame[role="menuitem"],iframe[role="menuitem"],input[role="menuitem"]:not([type=hidden]):not(:disabled),select[role="menuitem"]:not(:disabled),textarea[role="menuitem"]:not(:disabled),button[role="menuitem"]:not(:disabled),*[tabindex]:not([tabindex="-1"])';
1414
export const handleMouseUpByBlurring: MouseUpBlurHandler = ({currentTarget}) =>

0 commit comments

Comments
 (0)