Skip to content

Commit 36b3cdc

Browse files
authored
Fix model search being prefilled on dropdown (#5449)
1 parent 7d31966 commit 36b3cdc

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

.changeset/large-olives-wink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Fix model search being prefilled in dropdown to prevent confusion in available models

webview-ui/src/components/settings/ModelPicker.tsx

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const ModelPicker = ({
7070

7171
const { id: selectedModelId, info: selectedModelInfo } = useSelectedModel(apiConfiguration)
7272

73-
const [searchValue, setSearchValue] = useState(selectedModelId || "")
73+
const [searchValue, setSearchValue] = useState("")
7474

7575
const onSelect = useCallback(
7676
(modelId: string) => {
@@ -87,28 +87,25 @@ export const ModelPicker = ({
8787
}
8888

8989
// Delay to ensure the popover is closed before setting the search value.
90-
selectTimeoutRef.current = setTimeout(() => setSearchValue(modelId), 100)
90+
selectTimeoutRef.current = setTimeout(() => setSearchValue(""), 100)
9191
},
9292
[modelIdKey, setApiConfigurationField],
9393
)
9494

95-
const onOpenChange = useCallback(
96-
(open: boolean) => {
97-
setOpen(open)
95+
const onOpenChange = useCallback((open: boolean) => {
96+
setOpen(open)
9897

99-
// Abandon the current search if the popover is closed.
100-
if (!open) {
101-
// Clear any existing timeout
102-
if (closeTimeoutRef.current) {
103-
clearTimeout(closeTimeoutRef.current)
104-
}
105-
106-
// Delay to ensure the popover is closed before setting the search value.
107-
closeTimeoutRef.current = setTimeout(() => setSearchValue(selectedModelId), 100)
98+
// Abandon the current search if the popover is closed.
99+
if (!open) {
100+
// Clear any existing timeout
101+
if (closeTimeoutRef.current) {
102+
clearTimeout(closeTimeoutRef.current)
108103
}
109-
},
110-
[selectedModelId],
111-
)
104+
105+
// Clear the search value when closing instead of prefilling it
106+
closeTimeoutRef.current = setTimeout(() => setSearchValue(""), 100)
107+
}
108+
}, [])
112109

113110
const onClearSearch = useCallback(() => {
114111
setSearchValue("")

0 commit comments

Comments
 (0)