Keep the search view closed when its focus comes back late
tests / feature (8.4) (push) Successful in 1m49s
tests / feature (8.5) (push) Successful in 1m51s
tests / browser (chrome, chromium) (push) Successful in 7m34s
tests / browser (firefox, firefox) (push) Failing after 14m19s
tests / browser (safari, webkit) (push) Failing after 13m16s

On a slow machine Escape could close the full-screen search and have it
open again for good. A close hands focus back to the input — Escape does,
and so does the view's focus trap as it lets go — and `focused()` told
that return from someone coming to search by a 250ms wall-clock window.
Both returns run on frames, and a runner painting a few frames a second
took longer than that, so the returning focus opened the view again. A
`returning` flag now covers the close until the hand-back has actually
run, on the same frame, and the constant is gone.

`hold()` times the full-screen layout from the exit's own duration token,
the one Alpine's x-transition holds `display` for, instead of waiting a
frame or two for the exit's transitions to appear: `getAnimations()` is
empty both before an engine creates them and after they end, and a loaded
engine can leave a second between frames.

The browser tests were racing the same slow machine, reproduced in a
Linux container like the runner, with its Playwright Firefox and
WebKitGTK and two cores kept busy:

- The browser plugin retries every script and action with a one-second
  attempt until the budget runs out. An in-page sleep longer than that
  only ever passed on the last attempt, which is where the 47-50s tests
  came from, and a script that clicks was run again against a page that
  had moved on. `onceInPage()` runs such a script once however often it
  is retried; the long sleeps are plain retried conditions now.
- Under load WebKitGTK paints no frame while a tight setTimeout loop
  runs, so a sample loop saw the start value and then nothing.
  `caughtMidExit()` samples on animation frames, for 2.5s.
- "No animations running" is also true before an opening transition
  exists, so a close could be sampled from a scrim at 4% opacity.
  `settled()` waits two frames before it asks.

The workflow no longer uploads failure screenshots: Gitea's artifact
service timed out on every attempt, two minutes per red run, and the job
logs are readable without it.

Feature 1159 passed. Browser 299 passed on Chrome, Firefox and WebKit on
macOS, and on Firefox and WebKitGTK in the Linux container under load,
twice each.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Andreas Reinhold / reini
2026-09-18 09:49:17 +02:00
co-authored by Claude Opus 5
parent 8da8b1fa20
commit e7885ce1eb
8 changed files with 270 additions and 188 deletions
+15 -4
View File
@@ -538,9 +538,13 @@ it('opens the range picker full screen below 600px and grows its month list both
$page = dateProbe()
->resize(390, 800)
// Explicit, not implicit: the resize's own reflow can still be under way when the click
// that follows fires, which is what made this time out on a loaded runner the toggle's
// box kept moving under the click rather than the click itself being slow.
->assertScript('window.innerWidth === 390 && document.documentElement.getAnimations({ subtree: true }).length === 0');
// that follows fires, and the press it costs the runner is the one press this test cannot
// afford to lose. The browser plugin gives each attempt a second and then presses again,
// and once the full-screen picker is up it covers the toggle it came from — the month
// grid is what the browser finds there — so no later attempt can ever land. That is the
// 90 seconds (45s of attempts, then one last one with the whole budget) this timed out in.
->assertScript('window.innerWidth === 390')
->assertScript(settled('document.documentElement', subtree: true));
expect($page->script(hitTarget('[aria-controls=\"trip-field-picker\"][data-md-datepicker-toggle]')))->toBe('the target');
@@ -580,6 +584,11 @@ it('opens the range picker full screen below 600px and grows its month list both
$page->click(day('trip-field', '2026-09-20'))
->click(day('trip-field', '2026-09-24'))
// What Save is about to commit, read from the picker before it is pressed: a press that
// landed on another day — the month list grows both ways as it scrolls, so a cell can move
// under one — otherwise shows up only as the value never reaching the server, which says
// nothing about which half went wrong.
->assertScript("JSON.stringify({$scope}.draft) === '{\"start\":\"2026-09-20\",\"end\":\"2026-09-24\"}'")
->click('#trip-field-picker [data-md-datepicker-save]')
->assertSeeIn('#trip', '{"start":"2026-09-20","end":"2026-09-24"}')
->assertScript("! {$picker}.open");
@@ -590,7 +599,9 @@ it('closes the full-screen range picker from its app bar close button without ke
$page = dateProbe()
->resize(390, 800)
->assertScript('window.innerWidth === 390 && document.documentElement.getAnimations({ subtree: true }).length === 0');
// Settled before the press, as the test above says at length.
->assertScript('window.innerWidth === 390')
->assertScript(settled('document.documentElement', subtree: true));
expect($page->script(hitTarget('[aria-controls=\"trip-field-picker\"][data-md-datepicker-toggle]')))->toBe('the target');