Skip to content

Commit 55b49f0

Browse files
fix: re-establish focus after navigation for WebKit keyboard nav test (#193)
WebKit requires focus to be explicitly set after page navigation before Tab key navigation works correctly. Without this, pressing Tab results in focus going to BODY instead of the next focusable element. The fix re-focuses on the search input after form submission navigates to the search results page, establishing a proper focus context before pressing Tab to navigate to the next element.
1 parent e2827c3 commit 55b49f0

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

tests/e2e/specs/search-functionality.spec.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,17 @@ test.describe('Search Functionality', () => {
451451

452452
await page.waitForFunction(() => document.readyState === 'complete');
453453

454-
// Tab through results
454+
// WebKit requires focus to be explicitly established after page navigation
455+
// before Tab key navigation works correctly. Without this, WebKit returns
456+
// focus to BODY when Tab is pressed. Re-focus on the search input (which
457+
// now contains the query) to establish a proper focus context.
458+
const searchInputAfterNav = await getVisibleSearchInput(page);
459+
await searchInputAfterNav.focus();
460+
461+
// Tab to the next focusable element
455462
await page.keyboard.press('Tab');
456463

457-
// Check if a result link is focused
464+
// Check if a focusable element is focused (could be button, link, or input)
458465
const focusedElement = await page.evaluate(() => document.activeElement?.tagName);
459466
expect(['A', 'BUTTON', 'INPUT']).toContain(focusedElement);
460467
});

0 commit comments

Comments
 (0)