// Keyboard focus helpers shared by `Popover` and the table's filter popovers, // which both render into a portal at the end of `
`. Tab from the trigger // would otherwise skip past the box, and closing it would leave focus on // nothing. /** What Tab can reach. */ export const FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'; /** Move focus into `box`, unless it is already there: onto its first * focusable control, or onto the box itself when it has none. A control that * took focus on its own (a text field) keeps it. */ export function focusInto( box: HTMLElement | null, active: Element | null, ): void { if (!box || box.contains(active)) return; (box.querySelector