Commit 8d162d2
committed
fix(modal): keep dialog focus on present with cycle handle
When a sheet modal defaults handleBehavior to "cycle" (the new default on
major-9.0), the host becomes focusable and onModalFocus redirects focus to
the drag handle. present() (from #31260) focuses the shadow-DOM dialog
wrapper for screen readers, but that focus event is retargeted to the host
at the shadow boundary, so onModalFocus saw ev.target === el and bounced
focus onto the handle. The wrapper never kept focus, which failed the
"focus the sheet modal wrapper on present" e2e on Firefox.
Guard the redirect on el.shadowRoot.activeElement being null, which is true
only when the host itself was focused directly (e.g. tabbing into the
modal). When present() focuses the wrapper, activeElement is the wrapper, so
the redirect is skipped and the dialog focus is left intact. Tabbing to the
handle from outside still works.1 parent cff35f5 commit 8d162d2
1 file changed
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1188 | 1188 | | |
1189 | 1189 | | |
1190 | 1190 | | |
1191 | | - | |
1192 | | - | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
1193 | 1201 | | |
1194 | 1202 | | |
1195 | 1203 | | |
| |||
0 commit comments