Slide the sheets and close the search view out in Firefox too
The side sheet, the bottom sheet's panel and the docked search's scrim and view kept `display` alive through their exit with `transition-behavior: allow-discrete`. Firefox does not transition `display` (Chrome 117 and Safari 18 do), and `x-show` sets `display: none` in the frame the exit starts, so in Firefox the sheets vanished instead of sliding out and the search view and scrim vanished instead of fading. The docked search had a second problem in every engine: neither the view nor the scrim had a closed state to transition to, so where `display` was held (Chrome, Safari) the view stood at full opacity for its duration and then disappeared. Each element now carries `x-transition:enter`/`:leave="md-transition"`, the approach the two sheet scrims already took (renamed from `md-scrim-transition` to one name for all of them). The class only switches Alpine to CSS-transition mode, so `x-show` holds `display` for the element's computed transition-duration before hiding it, in every engine, and a reopen during the exit cancels the pending hide; nothing styles it. `display` and `allow-discrete` leave the transitions so Chrome and Safari do not hold a second time. Alpine reads the first `transition-duration` listed, which is the closing slide or fade in each list (the preset panel lists translate before height). The search view now closes back into the bar (opacity 0, `scale: 1 0.9`, the reverse of its `@starting-style` entry) and its scrim fades out on close and when the search turns full screen. Under reduced motion the durations are zero and every one of them closes at once. Four browser tests sample each exit mid-way in the page, in the same round trip as the close: the sheets part of the way to their closed offset, the search scrim and view part of the way faded, each still displayed, then `display: none`. All four fail on main in Firefox (the two search tests in Chrome too) and pass in Chrome, Firefox and Safari. OverlayTest pins the drawer's new transition and the view's markup. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
92e560bef6
commit
15e4fa7ed1
@@ -635,6 +635,68 @@ it('fades the bottom sheet\'s scrim out on close, rather than making it vanish',
|
||||
$page->assertScript("getComputedStyle({$scrim}).display === 'none'");
|
||||
});
|
||||
|
||||
it('slides the side sheet out on close, rather than making it vanish', function () {
|
||||
$sheet = "document.querySelector('#containment aside[role=\"dialog\"]')";
|
||||
$scrim = "{$sheet}.parentElement.querySelector(':scope > [data-md-drawer-scrim]')";
|
||||
|
||||
$page = containment()
|
||||
->click('#containment button:has-text("Side sheet")')
|
||||
->assertScript("getComputedStyle({$sheet}).display !== 'none'")
|
||||
->assertScript("Math.abs(parseFloat(getComputedStyle({$sheet}).translate)) < 0.5");
|
||||
|
||||
// Sampled in the page, in the same round trip as the close, as the scrim's fade is above: the
|
||||
// sheet must be caught still displayed and part of the way to its closed offset (one sheet
|
||||
// width past its edge), not gone at once — which is what Firefox showed while the exit leaned
|
||||
// on `allow-discrete` holding `display`.
|
||||
$midSlide = $page->script(<<<JS
|
||||
(async () => {
|
||||
const width = {$sheet}.getBoundingClientRect().width
|
||||
{$scrim}.click()
|
||||
|
||||
for (let i = 0; i < 60; i++) {
|
||||
const style = getComputedStyle({$sheet})
|
||||
const offset = Math.abs(parseFloat(style.translate) || 0)
|
||||
if (style.display !== 'none' && offset > 1 && offset < width - 1) return true
|
||||
await new Promise((resolve) => setTimeout(resolve, 5))
|
||||
}
|
||||
return false
|
||||
})()
|
||||
JS);
|
||||
|
||||
expect($midSlide)->toBeTrue();
|
||||
|
||||
$page->assertScript("getComputedStyle({$sheet}).display === 'none'");
|
||||
});
|
||||
|
||||
it('slides the bottom sheet down on close, rather than making it vanish', function () {
|
||||
$sheet = "document.querySelector('#containment section[role=\"dialog\"]')";
|
||||
$scrim = "{$sheet}.parentElement.querySelector(':scope > [data-md-bottom-sheet-scrim]')";
|
||||
$offset = "(parseFloat(getComputedStyle({$sheet}).translate.split(' ')[1]) || 0)";
|
||||
|
||||
$page = containment()
|
||||
->click('#containment button:has(> span:text-is("Bottom sheet"))')
|
||||
->assertScript("getComputedStyle({$sheet}).display !== 'none'")
|
||||
->assertScript("Math.abs({$offset}) < 0.5");
|
||||
|
||||
$midSlide = $page->script(<<<JS
|
||||
(async () => {
|
||||
const height = {$sheet}.getBoundingClientRect().height
|
||||
{$scrim}.click()
|
||||
|
||||
for (let i = 0; i < 60; i++) {
|
||||
const offset = {$offset}
|
||||
if (getComputedStyle({$sheet}).display !== 'none' && offset > 1 && offset < height - 1) return true
|
||||
await new Promise((resolve) => setTimeout(resolve, 5))
|
||||
}
|
||||
return false
|
||||
})()
|
||||
JS);
|
||||
|
||||
expect($midSlide)->toBeTrue();
|
||||
|
||||
$page->assertScript("getComputedStyle({$sheet}).display === 'none'");
|
||||
});
|
||||
|
||||
it('slides the side sheet in from its own edge in a right-to-left page', function () {
|
||||
Route::middleware('web')->get('/drawer-rtl-probe', fn () => Blade::render(<<<'BLADE'
|
||||
<!DOCTYPE html>
|
||||
|
||||
Reference in New Issue
Block a user