diff --git a/ui/src/App.tsx b/ui/src/App.tsx index e3cc8cd..2ece803 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -109,7 +109,7 @@ export default function App() { [pathOf], ); - const handleTreeSelect = useCallback( + const handleTreeActivate = useCallback( (row: Row) => { select(row.id); if (row.isDir) { @@ -203,10 +203,7 @@ export default function App() { [generation, select], ); - const handleTreeKeySelect = useCallback( - (row: Row) => select(row.id), - [select], - ); + const handleTreeSelect = useCallback((row: Row) => select(row.id), [select]); // Only a pure `ext:` filter is treated as the active type list; other queries start fresh. const { filter } = scan; @@ -422,7 +419,7 @@ export default function App() { onRevealed={handleRevealed} onToggle={scan.toggleExpand} onSelect={handleTreeSelect} - onKeySelect={handleTreeKeySelect} + onActivate={handleTreeActivate} onHoverRow={setHoveredId} onContext={handleContextMenu} onSort={scan.changeSort} diff --git a/ui/src/components/TreeView.tsx b/ui/src/components/TreeView.tsx index 010621f..efa2837 100644 --- a/ui/src/components/TreeView.tsx +++ b/ui/src/components/TreeView.tsx @@ -128,6 +128,7 @@ interface TreeRowProps { hoveredId: number | null; onToggle: (id: number) => void; onSelect: (row: Row) => void; + onActivate: (row: Row) => void; onHoverRow: (id: number | null) => void; onContext: (id: number, x: number, y: number) => void; } @@ -142,6 +143,7 @@ function TreeRow({ hoveredId, onToggle, onSelect, + onActivate, onHoverRow, onContext, }: RowComponentProps) { @@ -162,6 +164,7 @@ function TreeRow({ onClick={() => onSelect(row)} onDoubleClick={() => { if (row.isDir && row.hasChildren) onToggle(row.id); + onActivate(row); }} onContextMenu={(e) => { e.preventDefault(); @@ -308,9 +311,10 @@ export interface TreeViewProps { revealId: number | null; onRevealed: () => void; onToggle: (id: number) => void; + /** Click and arrow keys: select only, the treemap stays where it is. */ onSelect: (row: Row) => void; - /** Arrow-key selection: select only — Enter (onSelect) moves the view. */ - onKeySelect: (row: Row) => void; + /** Enter and double-click: move the treemap to the row. */ + onActivate: (row: Row) => void; onHoverRow: (id: number | null) => void; onContext: (id: number, x: number, y: number) => void; onSort: (key: SortKey) => void; @@ -328,7 +332,7 @@ export function TreeView({ onRevealed, onToggle, onSelect, - onKeySelect, + onActivate, onHoverRow, onContext, onSort, @@ -359,7 +363,7 @@ export function TreeView({ const action = navAction(e.key, flat, selectedIndex, expanded); if (!action) return; if (action.kind === "step") { - onKeySelect(flat[action.index].row); + onSelect(flat[action.index].row); listRef.current?.scrollToRow({ index: action.index, align: "smart", @@ -368,7 +372,7 @@ export function TreeView({ } else if (action.kind === "toggle") { onToggle(action.id); } else { - onSelect(action.row); + onActivate(action.row); } }; @@ -393,6 +397,7 @@ export function TreeView({ hoveredId, onToggle, onSelect, + onActivate, onHoverRow, onContext, }}