Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions scripts/capture-chrome-parity.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -82,10 +82,6 @@ const selectorGroups: Array<{ key: string; selector: string; pseudo?: string }>
{ key: "composer-pill-children", selector: 'form:has([data-testid="global-search-input"]) > div > *' },
{ key: "composer-input", selector: '[data-testid="global-search-input"]', pseudo: "::placeholder" },
{ key: "composer-buttons", selector: 'form:has([data-testid="global-search-input"]) button' },
{ key: "evidence-chip", selector: 'button[aria-label="Open evidence-backed answer sources"]' },
{ key: "evidence-chip-icon", selector: 'button[aria-label="Open evidence-backed answer sources"] svg' },
{ key: "scope-chip", selector: 'button[aria-label="Open source scope"]' },
{ key: "scope-chip-icon", selector: 'button[aria-label="Open source scope"] svg' },
{ key: "viewer-header", selector: "main header, body > div > header", pseudo: "::after" },
{ key: "viewer-composer", selector: 'form:has(input[placeholder^="Search or answer"])' },
{ key: "viewer-composer-children", selector: 'form:has(input[placeholder^="Search or answer"]) > *' },
Expand Down
11 changes: 10 additions & 1 deletion src/components/clinical-dashboard/master-search-header.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -641,11 +641,20 @@ export function MasterSearchHeader({
}
}

const restoreActionMenuFocusRef = useRef(false);
const closeScope = useCallback((restoreFocus = false) => {
restoreActionMenuFocusRef.current = restoreFocus;
setScopeOpen(false);
if (restoreFocus) actionMenuTriggerRef.current?.focus();
}, []);

useEffect(() => {
if (scopeOpen || !restoreActionMenuFocusRef.current) return;
restoreActionMenuFocusRef.current = false;
window.requestAnimationFrame(() => {
actionMenuTriggerRef.current?.focus({ preventScroll: true });
});
}, [scopeOpen]);

const closeScopeSheet = useCallback(() => {
setScopeSheetOpen(false);
window.requestAnimationFrame(() => actionMenuTriggerRef.current?.focus());
Expand Down
6 changes: 5 additions & 1 deletion src/components/use-dismissable-layer.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,11 @@ export function useDismissableLayer({
if (event.key !== "Escape") return;
event.preventDefault();
onDismiss("escape");
window.requestAnimationFrame(() => restoreFocusRef?.current?.focus({ preventScroll: true }));
window.requestAnimationFrame(() => {
window.requestAnimationFrame(() => {
restoreFocusRef?.current?.focus({ preventScroll: true });
});
});
}

document.addEventListener("pointerdown", handlePointerDown, true);
Expand Down
18 changes: 10 additions & 8 deletions tests/ui-accessibility.spec.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,17 +55,19 @@ async function expectDashboardUsable(page: Page) {
}

async function openScopeControl(page: Page) {
const actionMenu = page.getByRole("button", { name: "Open answer options" });
const trigger = page.getByRole("button", { name: "Open answer options" });
const menu = page.getByTestId("daily-actions-menu");

await expect(async () => {
await actionMenu.click();
const actionsMenu = page.getByTestId("daily-actions-menu");
await expect(actionsMenu).toBeVisible({ timeout: uiAssertionTimeoutMs });
await actionsMenu.getByRole("menuitem", { name: /^Scope\b/ }).click();
await expect(page.getByTestId("scope-command-popover")).toBeVisible({
timeout: uiAssertionTimeoutMs,
});
if (await menu.isVisible().catch(() => false)) return;
await trigger.click();
await expect(menu).toBeVisible({ timeout: uiAssertionTimeoutMs });
}).toPass({ timeout: 10_000 });

await menu.getByRole("menuitem", { name: "Scope", exact: true }).click();
await expect(page.locator('[data-testid="scope-command-popover"]:visible')).toBeVisible({
timeout: uiAssertionTimeoutMs,
});
}

test.describe("Clinical KB accessibility media smoke", () => {
Expand Down
4 changes: 3 additions & 1 deletion tests/ui-smoke.spec.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -1311,7 +1311,9 @@ test.describe("Clinical KB UI smoke coverage", () => {
expect(popoverMetrics.height).toBeLessThanOrEqual(Math.ceil(popoverMetrics.viewportHeight * 0.72));
await page.keyboard.press("Escape");
await expect(scopePopover).toBeHidden();
await expect(page.getByRole("button", { name: "Open answer options" })).toBeFocused();
await expect(async () => {
await expect(page.getByRole("button", { name: "Open answer options" })).toBeFocused();
}).toPass({ timeout: 5_000 });
await expectNoPageHorizontalOverflow(page);
});

Expand Down
Loading