Skip to content

Commit bfcb543

Browse files
fix(ui): fix global search — spinner/dropdown separation, keyboard nav, ProjectFileTree crash
- SearchBar: separate spinner from dropdown so `[data-testid="search-dropdown"]` only renders after results are loaded (not while loading). This ensures ArrowDown/Enter keyboard nav fires with results.length > 0. Spinner rendered independently when open && loading. - ProjectFileTree: guard total_files with ?? 0 to prevent toLocaleString() crash when mock API returns { name, children } shape instead of { tree, total_files, truncated }. Fixes gotoRoute timeout in file-tree search integration test. - All 11 search.spec.ts tests now pass on chromium. Co-Authored-By: Paperclip <noreply@paperclip.ing>
1 parent 95a8342 commit bfcb543

6 files changed

Lines changed: 640 additions & 16 deletions

File tree

src/main/frontend/src/components/ProjectFileTree.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,10 @@ export default function ProjectFileTree() {
382382
Project Files
383383
</p>
384384
<span className="text-[10px] text-muted-foreground/60 font-mono">
385-
{treeResponse!.total_files.toLocaleString()} files
385+
{(treeResponse!.total_files ?? 0).toLocaleString()} files
386386
</span>
387387
</div>
388-
<DensityBar value={treeResponse!.total_files} max={treeResponse!.total_files} />
388+
<DensityBar value={treeResponse!.total_files ?? 0} max={treeResponse!.total_files ?? 0} />
389389
{treeResponse!.truncated && (
390390
<p className="text-[9px] text-amber-500/80 mt-0.5">
391391
Tree truncated — showing partial results

src/main/frontend/src/components/SearchBar.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,28 +122,28 @@ export default function SearchBar() {
122122
)}
123123
</div>
124124

125-
{open && (
125+
{open && loading && (
126+
<div
127+
data-testid="search-spinner"
128+
className="absolute top-full mt-1 w-full z-50 glass-card flex items-center justify-center gap-2 p-4 text-surface-400 text-sm"
129+
>
130+
<Loader2 className="w-4 h-4 animate-spin" />
131+
Searching...
132+
</div>
133+
)}
134+
135+
{open && !loading && (
126136
<div
127137
data-testid="search-dropdown"
128138
id="search-listbox"
129139
role="listbox"
130140
className="absolute top-full mt-1 w-full z-50 glass-card max-h-80 overflow-y-auto"
131141
>
132-
{loading && (
133-
<div
134-
data-testid="search-spinner"
135-
className="flex items-center justify-center gap-2 p-4 text-surface-400 text-sm"
136-
>
137-
<Loader2 className="w-4 h-4 animate-spin" />
138-
Searching...
139-
</div>
140-
)}
141-
142-
{!loading && results.length === 0 && (
142+
{results.length === 0 && (
143143
<div className="p-4 text-center text-surface-400 text-sm">No results found</div>
144144
)}
145145

146-
{!loading && results.map((r, i) => (
146+
{results.map((r, i) => (
147147
<button
148148
key={r.id}
149149
role="option"

src/main/resources/static/assets/CodeGraphView-Dfos2jlw.js

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/static/assets/index-C9AZX9oo.js

Lines changed: 204 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)