/** * Focus custody for an edit session. * * Editing takes keyboard focus away from the grid and must give it back, or the * user's next arrow key goes nowhere and the cell they were on is lost. That * hand-off is easy to get subtly wrong in a dozen places, so it lives here: one * object captures focus on the way in and restores it on the way out. * * @packageDocumentation */ import type { ICellEditor } from '../types/cell-editor.types'; /** * Moves focus into an editor and returns it afterwards. * * One instance per grid; a session calls {@link capture} then * {@link focusInitial}, and {@link restore} on teardown. */ export declare class FocusManager { /** Where focus was when the session opened, so it can be handed back. */ private previous; /** * Remembers the currently-focused element. * * Call before mounting an editor. Records `null` for `` — restoring * focus *to the body* is the same as not restoring it, and pretending * otherwise would steal focus from wherever it legitimately moved on. */ capture(): void; /** * Gives focus back to the element {@link capture} recorded. * * Skipped when that element has since left the document — a recycled cell, a * collapsed row — because focusing a detached node silently moves focus to * `` and breaks grid keyboard navigation until the user clicks again. * * @param fallback - Focused instead when the captured element is gone; * typically the `.pg-cell` the session belonged to. */ restore(fallback?: HTMLElement | null): void; /** * Puts the caret where the user expects it when an editor opens. * * Prefers the editor's own {@link ICellEditor.focus} — only the editor knows * that, say, its search box matters and its option list does not. Falls back * to the first focusable descendant, then to the root itself. */ focusInitial(editor: ICellEditor, gui: HTMLElement): void; /** * Keeps Tab inside `container` until the returned disposer is called. * * Applied to popup editors only. An inline editor deliberately lets Tab * escape — that is how Tab-to-commit-and-move works — but a popup is a * self-contained surface, and tabbing out of one into the page behind it * leaves an orphaned editor open over content the user is now typing into. * * @returns Disposer that removes the trap. */ trap(container: HTMLElement): () => void; } //# sourceMappingURL=focus-manager.d.ts.map