Repository navigation
Commit 4e6c382
docs: keep drawer-toggle keyboard-focusable when drawer is open (#4608)
* keep drawer-toggle keyboard-focusable when drawer is open
The `.drawer-open` modifier set the toggle checkbox to `display: none`,
removing it from the keyboard tab order. For the responsive collapsible
icon-only drawer — which stays open on large screens via `lg:drawer-open`
and uses its button to toggle the sidebar *size* (icon-only <-> expanded)
rather than open/close it — this made the toggle impossible to operate
with the keyboard, while mouse users could still toggle it.
Drop `@apply hidden` so the checkbox falls back to the base
visually-hidden-but-focusable styling (`fixed h-0 w-0 opacity-0`). The
always-open panel visibility is unchanged (it is driven by the
`~ .drawer-side` sibling rules, not by the toggle's display), and keyboard
users can now focus the toggle and get the focus outline forwarded to the
`.drawer-button`.
Docs:
- add `drawer-button` to the icon-only example's toggle so the focus
outline forwards to the visible button
- add `lg:hidden` to the always-open example's input and to the docs site
layout's toggle input, to avoid a phantom (invisible, no focus ring)
tab stop at the lg breakpoint where the toggle button is already hidden
- fix a `$$$$drawer-button` prefix-placeholder typo in two code samples
Refs #4424
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* drawer: address review — keep core hidden, scope overrides to examples
Per review, don't change the component for everyone: `.drawer-open >
.drawer-toggle { @apply hidden }` is restored, and the exception is handled
locally in the one example that needs it.
- drawer.css: restore `@apply hidden` (revert the core change).
- docs/components/drawer: navbar example (`my-drawer-2`) is the one with the
real problem — it never uses `drawer-open`, so its toggle stayed focusable
at `lg` with no visible control; add `lg:hidden` to it.
- docs/components/drawer: always-visible example (`my-drawer-3`) doesn't need
`lg:hidden` — the core `hidden` under `lg:drawer-open` already covers it;
removed.
- docs/components/drawer: icon-only example (`my-drawer-4`) is the exception —
its button toggles the drawer size, so the toggle must stay focusable while
`drawer-open`. Add `inline` to override the core `hidden` locally.
- docs/+layout.svelte: revert the `lg:hidden` toggle. It only existed to
compensate for the core change; the layout uses `lg:drawer-open` when a
desktop sidebar exists, so the restored core `hidden` already handles it.
Verified with a Tailwind build (daisyUI + utilities) in Chromium:
| example | >= lg | < lg |
|----------------------|----------------------|-----------------|
| navbar + lg:hidden | none, not focusable | block, focusable|
| always-visible | none, not focusable | block, focusable|
| icon-only + inline | block, focusable | block, focusable|
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 374d637 commit 4e6c382
1 file changed
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
| 201 | + | |
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
| 222 | + | |
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
267 | | - | |
| 267 | + | |
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| |||
0 commit comments