Skip to content

Commit 7fa0832

Browse files
committed
add select all button
1 parent 36e6ef1 commit 7fa0832

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

packages/web/src/features/chat/components/chatBox/searchScopeSelector.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const SearchScopeSelector = React.forwardRef<
5757
) => {
5858
const scrollContainerRef = React.useRef<HTMLDivElement>(null);
5959
const scrollPosition = React.useRef<number>(0);
60+
const [hasSearchInput, setHasSearchInput] = React.useState(false);
6061

6162
const handleInputKeyDown = (
6263
event: React.KeyboardEvent<HTMLInputElement>
@@ -93,6 +94,10 @@ export const SearchScopeSelector = React.forwardRef<
9394
onSelectedSearchScopesChange([]);
9495
};
9596

97+
const handleSelectAll = () => {
98+
onSelectedSearchScopesChange(allSearchScopeItems);
99+
};
100+
96101
const handleTogglePopover = () => {
97102
onOpenChanged(!isOpen);
98103
};
@@ -180,10 +185,19 @@ export const SearchScopeSelector = React.forwardRef<
180185
<CommandInput
181186
placeholder="Search scopes..."
182187
onKeyDown={handleInputKeyDown}
188+
onValueChange={(value) => setHasSearchInput(!!value)}
183189
/>
184190
<CommandList ref={scrollContainerRef}>
185191
<CommandEmpty>No results found.</CommandEmpty>
186192
<CommandGroup>
193+
{!hasSearchInput && (
194+
<div
195+
onClick={handleSelectAll}
196+
className="flex items-center px-2 py-1.5 text-sm text-muted-foreground hover:text-foreground cursor-pointer transition-colors"
197+
>
198+
<span className="text-xs">Select all</span>
199+
</div>
200+
)}
187201
{sortedSearchScopeItems.map(({ item, isSelected }) => {
188202
return (
189203
<CommandItem

0 commit comments

Comments
 (0)