File tree 1 file changed +6
-4
lines changed
site/src/pages/WorkspacesPage/filter 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -64,12 +64,13 @@ const useAutocomplete = <TOption extends BaseOption = BaseOption>({
64
64
65
65
let options = searchOptionsQuery . data as TOption [ ]
66
66
67
- if ( ! selectedOption ) {
68
- return options
67
+ if ( selectedOption ) {
68
+ options = options . filter (
69
+ ( option ) => option . value !== selectedOption . value ,
70
+ )
71
+ options = [ selectedOption , ...options ]
69
72
}
70
73
71
- options = options . filter ( ( option ) => option . value !== selectedOption . value )
72
- options . unshift ( selectedOption )
73
74
options = options . filter (
74
75
( option ) =>
75
76
option . label . toLowerCase ( ) . includes ( query . toLowerCase ( ) ) ||
@@ -88,6 +89,7 @@ const useAutocomplete = <TOption extends BaseOption = BaseOption>({
88
89
const selectOption = ( option : TOption ) => {
89
90
let newSelectedOptionValue : TOption | undefined = option
90
91
selectedOptionsCacheRef . current [ option . value ] = option
92
+ setQuery ( "" )
91
93
92
94
if ( option . value === selectedOption ?. value ) {
93
95
newSelectedOptionValue = undefined
You can’t perform that action at this time.
0 commit comments