Skip to content

Clicking the empty space in the sidebar file tree now clears the…#153

Merged
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync
Jun 15, 2026
Merged

Clicking the empty space in the sidebar file tree now clears the…#153
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync

Conversation

@inkeep-oss-sync

Copy link
Copy Markdown
Contributor

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.

… + 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

@inkeep-internal-ci inkeep-internal-ci Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@inkeep-oss-sync inkeep-oss-sync Bot merged commit e96601a into main Jun 15, 2026
@inkeep-oss-sync inkeep-oss-sync Bot deleted the copybara/sync branch June 15, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant