Skip to content

Commit d3e0c3c

Browse files
shengslogarSheng SlogarRobinMalfait
authored
Support <summary> as a focusable element (#3389)
- [`<summary>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary) is a built-in heading tag that is nested inside a [`<details>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details) tag to toggle its contents. It's keyboard tab-able by default and not currently recognized by Headless UI. - There are no attributes that disable a summary tag, and adding `tabindex="-1"` makes it behave like any other normally-tab-able element. - I didn't spot any tests that specifically check for tab-ability of elements outside of buttons and inputs. Let me know if I missed anything. --------- Co-authored-by: Sheng Slogar <[email protected]> Co-authored-by: Robin Malfait <[email protected]>
1 parent 8afe84d commit d3e0c3c

File tree

6 files changed

+12
-0
lines changed

6 files changed

+12
-0
lines changed

packages/@headlessui-react/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Ensure we are not freezing data when the `static` prop is used ([#3779](https://github.com/tailwindlabs/headlessui/pull/3779))
1313
- Ensure `onChange` types are contravariant instead of bivariant ([#3781](https://github.com/tailwindlabs/headlessui/pull/3781))
14+
- Support `<details>` as a focusable element without `<summary>` ([#3389](https://github.com/tailwindlabs/headlessui/pull/3389))
15+
- Support `<summary>` as a focusable element inside `<details>` ([#3389](https://github.com/tailwindlabs/headlessui/pull/3389))
1416

1517
## [2.2.7] - 2025-07-30
1618

packages/@headlessui-react/src/test-utils/interactions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ let focusableSelector = [
489489
'iframe',
490490
'input:not([disabled])',
491491
'select:not([disabled])',
492+
'details:not(:has(> summary))',
493+
'details>summary',
492494
'textarea:not([disabled])',
493495
]
494496
.map(

packages/@headlessui-react/src/utils/focus-management.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export let focusableSelector = [
1515
'iframe',
1616
'input:not([disabled])',
1717
'select:not([disabled])',
18+
'details:not(:has(> summary))',
19+
'details>summary',
1820
'textarea:not([disabled])',
1921
]
2022
.map(

packages/@headlessui-vue/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- Fix restoring focus to correct element when closing `Dialog` component ([#3365](https://github.com/tailwindlabs/headlessui/pull/3365))
1919
- Cleanup `process` in Combobox component when using virtualization ([#3495](https://github.com/tailwindlabs/headlessui/pull/3495))
2020
- Ensure outside click properly works when clicking SVG elements ([#3777](https://github.com/tailwindlabs/headlessui/pull/3777))
21+
- Support `<details>` as a focusable element without `<summary>` ([#3389](https://github.com/tailwindlabs/headlessui/pull/3389))
22+
- Support `<summary>` as a focusable element inside `<details>` ([#3389](https://github.com/tailwindlabs/headlessui/pull/3389))
2123

2224
## [1.7.22] - 2024-05-08
2325

packages/@headlessui-vue/src/test-utils/interactions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ let focusableSelector = [
467467
'iframe',
468468
'input:not([disabled])',
469469
'select:not([disabled])',
470+
'details:not(:has(> summary))',
471+
'details>summary',
470472
'textarea:not([disabled])',
471473
]
472474
.map(

packages/@headlessui-vue/src/utils/focus-management.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export let focusableSelector = [
1313
'iframe',
1414
'input:not([disabled])',
1515
'select:not([disabled])',
16+
'details:not(:has(> summary))',
17+
'details>summary',
1618
'textarea:not([disabled])',
1719
]
1820
.map(

0 commit comments

Comments
 (0)