fix(web): preserve selection on root reveal

Co-authored-by: Exotic <[email protected]>
This commit is contained in:
t3-code[bot]andExotic committed 2026-08-16 01:05:59 +00:00
1 parent bfdf3c63b3
commit 94a2fd88ce
2 files changed
+14 -13

No files matched your search

@@ -59,7 +59,7 @@ The goal is not to minimize CSS or class counts at any cost. The goal is to put
- Preserve runtime top and bottom overflow state. Do not replace dynamic fades with an always-on static mask.
- Preserve fade geometry and keep the native scrollbar lane opaque so the track and thumb stay visible and usable. A visually similar mask that fades the scrollbar is a regression.
- For path-driven tree actions with flattened directory rows, do not assume that every registered item path is currently visible. Resolve the target through the tree's visible projection before selecting, focusing, or scrolling, and verify intermediate directory actions against a real flattened chain.
- Treat external tree-reveal requests as one-shot events: resolve and validate the visible target without mutating search, focus, or selection, then acknowledge or clear the request after success so component remounts cannot replay stale navigation.
- Treat external tree-reveal requests as one-shot events: resolve and validate the visible target without mutating search, focus, or selection, then acknowledge or clear the request after success so component remounts cannot replay stale navigation. A project-root reveal should scroll the tree viewport itself and preserve the current selected item; raw entry order is not visible row order.
- Verify actual scroll behavior when changing virtualizers, masks, overflow ownership, or scrollbar selectors. Source-level class comparison is not enough.
## Visual and layout preservation
@@ -361,13 +361,13 @@ export default function FileBrowserPanel({
? `${breadcrumbRevealPath}/`
: breadcrumbRevealPath;
const item = itemPath ? (model.getItem(itemPath) ?? model.getItem(breadcrumbRevealPath)) : null;
const firstEntry = entries[0];
const rootItemPath = firstEntry
? firstEntry.kind === "directory"
? visibleDirectoryTreePath(entries, firstEntry.path)
: firstEntry.path
: null;
if ((breadcrumbRevealPath && !item) || (!breadcrumbRevealPath && !rootItemPath)) return;
const rootScrollContainer =
breadcrumbRevealPath === ""
? model
.getFileTreeContainer()
?.shadowRoot?.querySelector<HTMLElement>("[data-file-tree-virtualized-scroll]")
: null;
if ((breadcrumbRevealPath && !item) || (!breadcrumbRevealPath && !rootScrollContainer)) return;
const visibleItemPath = itemPath
? entryKind === "directory"
@@ -379,8 +379,10 @@ export default function FileBrowserPanel({
handledBreadcrumbRevealRef.current = revealRequest;
syncingSelectionRef.current = true;
model.closeSearch();
for (const path of model.getSelectedPaths()) {
model.getItem(path)?.deselect();
if (visibleItemPath) {
for (const path of model.getSelectedPaths()) {
model.getItem(path)?.deselect();
}
}
const segments = breadcrumbRevealPath.split("/").filter(Boolean);
@@ -394,8 +396,8 @@ export default function FileBrowserPanel({
if (visibleItemPath) {
model.getItem(visibleItemPath)?.select();
model.scrollToPath(visibleItemPath, { focus: true, offset: "center" });
} else if (rootItemPath) {
model.scrollToPath(rootItemPath, { focus: true, offset: "top" });
} else if (rootScrollContainer) {
rootScrollContainer.scrollTop = 0;
}
onBreadcrumbRevealHandled(breadcrumbRevealId);
queueMicrotask(() => {
@@ -408,7 +410,6 @@ export default function FileBrowserPanel({
entryKinds,
model,
onBreadcrumbRevealHandled,
treePaths,
]);
// Tag tree drags with the composer mention payload. The row is read from