Close only the topmost layer on Escape, and keep a layer opened over a sheet readable
A modal side sheet, bottom sheet or the modal rail closed on any Escape the window heard, so a dialog opened from a sheet, a menu, select list or searchable choice inside one, a sheet opened from a sheet, and a sheet inside a dialog each closed two layers on one press. And a dialog or a second sheet rendered elsewhere on the page sat inside the `aria-hidden` the first sheet's `x-trap.inert` put on its siblings, so a screen reader could not read it, while the sheet's focus trap took every Tab inside the dialog back to the inert sheet. resources/js/layers.js adds `x-layer`, on each of those panels beside its `x-trap`. An Escape is the panel's only when nothing has handled it and the nearest open layer around its target is the panel itself - not an open dialog, popover or customizable select, nor a panel inside it; the panel claims it with preventDefault(), which also keeps a dialog around it from cancelling, and dispatches `material-escape`, which the views close on. A panel that opens lifts `aria-hidden` from its own ancestors and puts it back on close only where a panel still open hides them; materialShowModal() does the same for `<x-modal>`, whose new `x-trap.noautofocus.noreturn` pauses the sheet's focus trap while it is open and moves no focus of its own. The searchable choice, the search view and the supporting pane's sheet now preventDefault() the Escape they act on, so the dialog or sheet around them stays. Four browser tests stack the layers every way above and fail without the change in Chrome. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
029c78d301
commit
94a376a4fd
@@ -194,6 +194,10 @@ it('puts a side sheet\'s actions on the left, in M3\'s 72dp row', function () {
|
||||
it('slides a side sheet in from either edge', function () {
|
||||
expect((string) $this->blade('<x-drawer title="Details" with-close-button>Body</x-drawer>'))
|
||||
->toContain('x-trap.inert.noscroll="open && ! wide"')
|
||||
// One layer among others: an Escape above or inside it is not its own (resources/js/layers.js).
|
||||
->toContain('x-layer="open && ! wide"')
|
||||
->toContain('x-on:material-escape="close()"')
|
||||
->not->toContain('keydown.window.escape')
|
||||
->toContain('x-bind:data-md-drawer-collapsed="collapsed ? \'\' : null"')
|
||||
->toContain('x-effect="settle(open)"')
|
||||
->toContain('data-md-side="end"')
|
||||
@@ -208,6 +212,7 @@ it('draws a modal bottom sheet with a drag handle, or a standard one without a s
|
||||
->toContain('...materialBottomSheet(false, JSON.parse(')
|
||||
->toContain('data-md-bottom-sheet-scrim')
|
||||
->toContain('x-trap.inert.noscroll="open"')
|
||||
->toContain('x-layer="open" x-on:material-escape="close()"')
|
||||
->toContain('data-md-bottom-sheet-panel')
|
||||
->toContain('data-md-bottom-sheet-handle')
|
||||
->toContain('data-md-bottom-sheet-grip')
|
||||
|
||||
Reference in New Issue
Block a user