fix(ui): preserve upstream sidebar and selection behavior
This commit is contained in:
@@ -55,4 +55,14 @@ describe('selectFolderIdsForProjection', () => {
|
||||
expect([...selectFolderIdsForProjection(folders, { archivedBucket: true, searchQuery: 'matching' })])
|
||||
.toEqual(['root', 'child']);
|
||||
});
|
||||
|
||||
test('keeps a fuzzy folder match and its ancestor', () => {
|
||||
const folders = [
|
||||
{ id: 'root', name: 'Root', parentId: null, nodeCount: 0 },
|
||||
{ id: 'child', name: 'Release Notes', parentId: 'root', nodeCount: 0 },
|
||||
];
|
||||
|
||||
expect([...selectFolderIdsForProjection(folders, { archivedBucket: false, searchQuery: 'release-notes' })])
|
||||
.toEqual(['root', 'child']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { getRuntimeKey } from '@/lib/runtime-switch';
|
||||
import { matchesRankQuery } from '@/lib/search/fuzzySearch';
|
||||
import { normalizePath } from '@/lib/pathNormalization';
|
||||
import { resolveGlobalSessionDirectory } from '@/stores/useGlobalSessionsStore';
|
||||
import { getPinnedSessionKey } from '@/stores/useSessionPinnedStore';
|
||||
@@ -227,7 +228,7 @@ export const selectFolderIdsForProjection = (
|
||||
keep = (childIdsByParentId.get(folderId) ?? []).some(shouldKeep);
|
||||
} else {
|
||||
if (!keep && !options.searchQuery) keep = true;
|
||||
if (!keep && (entry.nodeCount > 0 || entry.name.toLowerCase().includes(options.searchQuery))) keep = true;
|
||||
if (!keep && (entry.nodeCount > 0 || matchesRankQuery([entry.name], options.searchQuery))) keep = true;
|
||||
if (!keep) keep = (childIdsByParentId.get(folderId) ?? []).some(shouldKeep);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user