Contain circuit editor scrolling
This commit is contained in:
@@ -482,7 +482,7 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
|
||||
setAnchorRowKey(null);
|
||||
}
|
||||
setSelectedCell({ rowKey: row.rowKey, cellKey });
|
||||
requestAnimationFrame(() => containerRef.current?.focus());
|
||||
focusGridWithoutScroll();
|
||||
}
|
||||
|
||||
// Captures semantic identity for post-reload focus restoration.
|
||||
@@ -556,7 +556,7 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
|
||||
}
|
||||
await loadTree({ showLoading: false });
|
||||
if (!intent) {
|
||||
requestAnimationFrame(() => containerRef.current?.focus());
|
||||
focusGridWithoutScroll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -779,7 +779,7 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
|
||||
if (resolved) {
|
||||
setSelectedCell(resolved);
|
||||
}
|
||||
requestAnimationFrame(() => containerRef.current?.focus());
|
||||
focusGridWithoutScroll();
|
||||
}, [data, editableCells, visibleRows]);
|
||||
|
||||
// Restores multi-selected device rows after operations that rebuild row keys.
|
||||
@@ -870,6 +870,10 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
|
||||
return row?.cells.find((cell) => cell.cellKey === cellKey);
|
||||
}
|
||||
|
||||
function focusGridWithoutScroll() {
|
||||
requestAnimationFrame(() => containerRef.current?.focus({ preventScroll: true }));
|
||||
}
|
||||
|
||||
// Opens edit session for selected cell.
|
||||
// Enter/F2/double-click use selectExisting; type-to-edit uses replaceWithTypedChar.
|
||||
function startEdit(cell: SelectedCell, mode: StartEditMode, typedChar?: string) {
|
||||
@@ -1169,7 +1173,7 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
|
||||
}
|
||||
setEditingCell(null);
|
||||
setSelectedCell({ rowKey: editingCell.rowKey, cellKey: editingCell.cellKey });
|
||||
requestAnimationFrame(() => containerRef.current?.focus());
|
||||
focusGridWithoutScroll();
|
||||
}
|
||||
|
||||
async function handleAddReserveCircuit(sectionId: string, afterCircuitId?: string) {
|
||||
@@ -3164,7 +3168,7 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
|
||||
const active = document.activeElement as HTMLElement | null;
|
||||
if (!active || !containerRef.current?.contains(active)) {
|
||||
setEditingCell(null);
|
||||
requestAnimationFrame(() => containerRef.current?.focus());
|
||||
focusGridWithoutScroll();
|
||||
}
|
||||
});
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user