@@ -21,7 +21,6 @@ import React, {
21
21
useCallback ,
22
22
useContext ,
23
23
useEffect ,
24
- useLayoutEffect ,
25
24
useMemo ,
26
25
useState ,
27
26
} from "react" ;
@@ -184,37 +183,26 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", onFinished }) =>
184
183
} ) ;
185
184
} , [ cli , query ] ) ;
186
185
187
- // Reset the selection back to the first item whenever the query changes
188
- useLayoutEffect ( ( ) => {
189
- rovingContext . dispatch ( {
190
- type : Type . SetFocus ,
191
- payload : {
192
- ref : rovingContext . state . refs [ 0 ] ,
193
- } ,
194
- } ) ;
195
- } , [ query ] ) ; // eslint-disable-line react-hooks/exhaustive-deps
196
-
197
186
const activeSpace = SpaceStore . instance . activeSpaceRoom ;
198
187
const [ spaceResults , spaceResultsLoading ] = useSpaceResults ( activeSpace , query ) ;
199
188
200
189
const setQuery = ( e : ChangeEvent < HTMLInputElement > ) : void => {
201
190
const newQuery = e . currentTarget . value ;
202
191
_setQuery ( newQuery ) ;
203
- if ( ! query !== ! newQuery ) {
204
- setImmediate ( ( ) => {
205
- // reset the activeRef when we start/stop querying as the view changes
206
- const ref = rovingContext . state . refs [ 0 ] ;
207
- if ( ref ) {
208
- rovingContext . dispatch ( {
209
- type : Type . SetFocus ,
210
- payload : { ref } ,
211
- } ) ;
212
- ref . current ?. scrollIntoView ( {
213
- block : "nearest" ,
214
- } ) ;
215
- }
216
- } ) ;
217
- }
192
+
193
+ setImmediate ( ( ) => {
194
+ // reset the activeRef when we change query for best usability
195
+ const ref = rovingContext . state . refs [ 0 ] ;
196
+ if ( ref ) {
197
+ rovingContext . dispatch ( {
198
+ type : Type . SetFocus ,
199
+ payload : { ref } ,
200
+ } ) ;
201
+ ref . current ?. scrollIntoView ( {
202
+ block : "nearest" ,
203
+ } ) ;
204
+ }
205
+ } ) ;
218
206
} ;
219
207
220
208
const viewRoom = ( roomId : string , persist = false ) => {
0 commit comments