fix: keep File Explorer highlight in sync with the active file - #530
fix: keep File Explorer highlight in sync with the active file#530suhailopensource wants to merge 1 commit into
Conversation
74cffdd to
c5a2863
Compare
|
hey @suhailopensource , Two issues with Shift+click range selection here:
Worth a manual pass on file Shift+click before merging — these compound. |
working on it will address it by today. |
The file-tree row highlight has two independent sources: the active document (activeFile.source) and react-arborist's own selection (node.isSelected), which is set on click and never cleared. They desync whenever the active document changes by any means other than a tree click — switching tabs from the tab bar, or closing all tabs — leaving the previously selected row highlighted, or two rows highlighted at once. Drive the tree selection from the active document instead. With an active document, select() replaces the previous selection and scrolls the row into view (replacing the bare scrollTo), so exactly one row is lit; with none, only the selected ids are cleared. Both paths keep react-arborist's selection anchor intact — deselectAll() nulls it, and selectContiguous() (Shift+click) has no range to select without one. focus: false keeps the sync purely visual, and a cancelled guard avoids a stale select during rapid tab switches. A range selection now also keeps its background on every row it covers, including the active file, which previously kept the single-selection style and made a file range look broken up. Fixes VoidenHQ#528
c5a2863 to
05df466
Compare
|
@phurpa-tsering done addressed ur review comments |
Problem
Closes #528. In the File Explorer a row's highlight comes from two independent sources — the active document (
activeFile.source) and react-arborist's own selection (node.isSelected, set on click and never cleared). Clicking a file sets both, but every other way of changing the active document leaves the selection stale:activeFilebecomesnullbut the last-clicked row stays selected, so it remains highlighted.activeFilemoves while the tree selection stays on the last-clicked file, so two rows are highlighted at once.Fix
Drive the tree selection from the active document in the existing
activeFile?.sourceeffect (apps/ui/src/core/file-system/components/FileSystemList.tsx):deselectAll(), so no row stays highlighted.select(source, { focus: false })(replacing the barescrollTo), which clears any previous selection and scrolls the row into view, so exactly one row — the active file — is lit.focus: falsekeeps it a purely visual sync, and acancelledguard avoids a stale select during rapid tab switches.Testing
yarn typecheck(apps/ui): no new type errors from this change.