Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions apps/web/src/components/RightPanelTabs.keyboard.browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,13 @@ describe("right panel new-tab shortcut", () => {
expect(document.querySelector('[role="menu"]')).not.toBeNull();
await press("Escape");
expect(document.querySelector('[role="menu"]:not([data-closed])')).toBeNull();
// The menu hands focus back to its trigger once its close finishes, which can land a frame later.
await vi.waitFor(() =>
expect(document.activeElement).toBe(
container.querySelector('[aria-label="Add panel surface"]'),
),
);
// The menu hands focus back to its trigger once its close finishes, a few frames later.
// Timers are fake here, so advance them instead of polling in real time.
const trigger = container.querySelector('[aria-label="Add panel surface"]');
for (let frame = 0; frame < 10 && document.activeElement !== trigger; frame++) {
await act(() => vi.advanceTimersToNextFrame());
}
expect(document.activeElement).toBe(trigger);
input.remove();
});

Expand Down
Loading