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
+9 -4
View File
@@ -906,10 +906,13 @@ it('opens a sheet-at-compact menu below 600px, focused on its first item, and th
->assertScript(focused("textContent.trim() === 'Photo'"));
// From 600px the trigger opens the popover instead, and a resize across it while one is open
// closes whichever was shown.
// closes whichever was shown. `aria-haspopup` is how the trigger says what it opens now, and
// the menu writes it in the same handler as that close — so waiting for it is waiting for the
// component to have heard of the new width. A press that lands before the media query's change
// event is delivered, which a loaded runner leaves room for, is closed again by it a moment on.
$page->resize(900, 800)
->click($trigger)
->assertAttribute($trigger, 'aria-haspopup', 'menu')
->click($trigger)
->assertAttribute($trigger, 'aria-expanded', 'true');
$page->resize(400, 800)
@@ -1023,8 +1026,10 @@ it('fades a menu out after the browser has closed it, on Escape or a press outsi
->assertScript(EXIT_COPY_FADING)
// The copy is decoration: Alpine starts nothing inside it.
->assertScript("window.eval(\"[...document.querySelectorAll('[data-md-popover-ghost], [data-md-popover-ghost] *')].every((element) => element._x_dataStack === undefined)\")")
// Gone once the slowest of its transitions has run.
->assertScript('new Promise((resolve) => setTimeout(() => resolve(document.querySelector("[data-md-popover-ghost]") === null), 3300))');
// Gone once the slowest of its transitions has run: assertScript's own retry waits for it,
// where sleeping for the exit's length inside the page outlived the plugin's 1000ms budget
// for one script attempt and had the whole expectation run again until it timed out.
->assertScript('document.querySelector("[data-md-popover-ghost]") === null');
// A press outside it.
$page->click(MORE)