Clicking the empty space in the sidebar file tree now clears the…#153
Merged
Conversation
… + empty-space click (#1857) * fix(open-knowledge): drag-and-drop can promote a folder to project root Dropping a nested folder (or file) onto the sidebar file tree's empty content area now moves it back to the project root; previously items could only be dropped onto another folder, so unwanted nesting was unrecoverable by drag. The native drag gesture is owned by @pierre/trees. Its stock build only emits a `kind: 'root'` drop target when the pointer is over a top-level file row, so an empty-space drop was a silent no-op. Patch `resolveDropTargetFromElement` to resolve the empty virtualized-scroll area to a root target (both dragover preview and point-based drop re-resolution route through it), and tag the tree root with `data-file-tree-root-drag-target` so the app paints a container-level drop ring via unsafeCSS. The destination math (`computeTreeDropDestinationPath`) and the `/api/rename-path` move spine already handle root targets, so no app-side move logic changed. Closes PRD-7043 * fix(open-knowledge): WHCM fallback + file-promotion e2e for drag-to-root Address PR review: - Add a forced-colors (Windows High Contrast) fallback for the drop-to-root ring — box-shadow + color-mix backgrounds are suppressed in WHCM, so fall back to a system Highlight border (mirrors the JSX in-range halo fallback in globals.css). - Extend the drag-to-root e2e to also promote a nested *file* to root, exercising handleDropComplete's distinct `kind: 'file'` /api/rename-path branch (folder case already covered). Shared the DnD-dispatch helper. * feat(open-knowledge): empty-space click clears create target to project root Clicking the file tree's empty content area now "deselects" the active item for creation purposes: New File / New Folder (toolbar, template cascade, and the native File menu) land at the project root instead of next to the open doc. The editor view is untouched — whatever was open stays open. Selecting a row or navigating elsewhere re-couples creation to that item's folder. FileTree owns a `creationDirCleared` flag: an empty-space left-click in the scroll content area sets it; a row selection or any activeTarget change resets it. When set, `activeTreePath` resolves to null so `useSelectionMirror` drops the row highlight without disturbing `activeTarget`. The flag is exposed to FileSidebar via `FileTreeHandle.isCreationTargetCleared()` (the handle now multiplexes a local listener set alongside Pierre's model.subscribe, since React state changes aren't observed by the tree model); FileSidebar maps it to `initialCreateDir = '' `. * test(open-knowledge): add isCreationTargetCleared to FileSidebar menu-action mock The menu-action DOM test's FileTree-handle mock also needs the new isCreationTargetCleared() method or FileSidebar's subscription sync throws. Sibling fix to FileSidebar.dom.test.tsx. * fix(open-knowledge): clear the focus ring after empty-space deselect After an empty-space click cleared the creation target, the previously active row kept a lingering blue focus ring. Pierre uses roving focus and restores DOM focus to its focused row, so blurring it doesn't stick. Instead, suppress the ring visually: the React wrapper forwards `data-ok-creation-cleared` onto the <file-tree-container> host while cleared, and unsafeCSS neutralizes `--trees-focus-ring-color` on the focused row via `:host([…])`. The ring redraws the instant a row is selected or navigation re-couples. E2E asserts the focused row's resolved --trees-focus-ring-color is a real color before the empty-space click and transparent after. --------- GitOrigin-RevId: ce0de6d7ca9e898e01936720e077933e9a5a2be9
Contributor
There was a problem hiding this comment.
Automated approval from agents-private public-mirror-sync (run: https://github.com/inkeep/agents-private/actions/runs/27554546255). Source of truth is the monorepo; direct edits on inkeep/open-knowledge are overwritten on next sync.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clicking the empty space in the sidebar file tree now clears the selection so that New File and New Folder create at the project root. The document you had open stays open in the main view — only the create target changes. Selecting another item, or navigating elsewhere, re-points creation at that item's folder as before.
Fix drag-and-drop so a nested folder can be moved back to the project root. Dragging a folder (or file) onto the empty space in the sidebar file tree now promotes it to the top level, with a highlight showing where it will land. Previously you could only drop items onto another folder, so there was no way to undo unwanted nesting by dragging.