Commit 78fabd8
fix(snackbar): only pause on keyboard focus using :focus-visible (#1209)
* fix(snackbar): only pause on keyboard focus using :focus-visible
Previously, onFocus handler would pause the snackbar timer on any focus
event including mouse clicks/taps. This caused the snackbar to persist
indefinitely when clicked.
Now uses :focus-visible to detect keyboard-initiated focus:
- Keyboard Tab → pause timer (accessibility for screen reader users)
- Mouse click → don't pause (timer continues normally)
- If :focus-visible not supported → don't pause (safe fallback)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs
* fix(snackbar): remove unnecessary :focus-within check
:focus-within doesn't distinguish between keyboard and mouse focus,
so it would cause pause on mouse click as well. Since :focus-visible
is applied to the focused element itself (including buttons focused
via keyboard), checking event.target.matches(":focus-visible") alone
is sufficient.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* docs: changeset
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent 800f9a8 commit 78fabd8
File tree
4 files changed
+19
-3
lines changed- .changeset
- packages/react-headless/snackbar
- src
4 files changed
+19
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| 149 | + | |
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
| |||
189 | 191 | | |
190 | 192 | | |
191 | 193 | | |
192 | | - | |
193 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
194 | 202 | | |
195 | 203 | | |
196 | 204 | | |
| |||
221 | 229 | | |
222 | 230 | | |
223 | 231 | | |
| 232 | + | |
224 | 233 | | |
225 | 234 | | |
226 | 235 | | |
0 commit comments