From c72908458bdfffa6c19c31b5b1d920d1a24edccb Mon Sep 17 00:00:00 2001 From: Andreas Reinhold / reini Date: Mon, 14 Sep 2026 19:50:35 +0200 Subject: [PATCH] Wait for the timepicker dialog to actually open before focusing it The period-selector arrow-key test called .focus() on the AM/PM radio right after clicking the field. show() moves focus into the dialog from Alpine's $nextTick, which Livewire's bundled Alpine defers with a real setTimeout(0), not a microtask, so the dialog was still closed when .focus() ran and it silently did nothing, leaving the arrow key with no effect (step 36 batch: browser tests for the datepicker/ timepicker rewrite). Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9 --- tests/Browser/TimepickerTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/Browser/TimepickerTest.php b/tests/Browser/TimepickerTest.php index 2a752d11..85edb8d9 100644 --- a/tests/Browser/TimepickerTest.php +++ b/tests/Browser/TimepickerTest.php @@ -346,7 +346,13 @@ it('moves the period selector between AM and PM with arrow keys, as a radio grou ->click('#meeting') ->assertAttribute($am, 'role', 'radio') ->assertAttribute($am, 'aria-checked', 'true') - ->assertAttribute($pm, 'aria-checked', 'false'); + ->assertAttribute($pm, 'aria-checked', 'false') + // show() moves focus to the dial from inside Alpine's $nextTick, which Livewire's bundled + // Alpine defers with a real setTimeout(0) rather than a microtask: wait for the dialog to + // actually open before stealing focus onto the period selector, or .focus() below is a no-op + // on a still-closed and the element beneath it keeps focus instead. + ->wait(0.15) + ->assertScript("document.querySelector('#meeting-dialog').open"); $page->script("document.querySelector('{$am}').focus()");