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
16 changes: 16 additions & 0 deletions src/utils/focusManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Focus management utilities
export function getFocusableElements(container: HTMLElement): HTMLElement[] {
const selectors = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=""-1""])';
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Malformed CSS selector for tabindex will cause querySelectorAll to fail at runtime.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/focusManager.ts, line 3:

<comment>Malformed CSS selector for tabindex will cause `querySelectorAll` to fail at runtime.</comment>

<file context>
@@ -0,0 +1,16 @@
+// Focus management utilities
+export function getFocusableElements(container: HTMLElement): HTMLElement[] {
+  const selectors = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=""-1""])';
+  return Array.from(container.querySelectorAll(selectors));
+}
</file context>
Fix with Cubic

return Array.from(container.querySelectorAll(selectors));
}
export function saveFocus(): () => void {
const activeElement = document.activeElement as HTMLElement | null;
return () => activeElement?.focus();
}
export function moveFocus(direction: 'next' | 'prev'): void {
const focusable = getFocusableElements(document.body);
const currentIndex = focusable.indexOf(document.activeElement as HTMLElement);
if (currentIndex === -1) return;
const nextIndex = direction === 'next' ? (currentIndex + 1) % focusable.length : (currentIndex - 1 + focusable.length) % focusable.length;
focusable[nextIndex]?.focus();
}
Loading