mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 04:21:57 +03:00
Tweak spotlight roving behaviour to reset when changing query (#7656)
This commit is contained in:
parent
b77d31bb4f
commit
51446378e3
1 changed files with 11 additions and 0 deletions
|
@ -21,6 +21,7 @@ import React, {
|
|||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
|
@ -183,6 +184,16 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", onFinished }) =>
|
|||
});
|
||||
}, [cli, query]);
|
||||
|
||||
// Reset the selection back to the first item whenever the query changes
|
||||
useLayoutEffect(() => {
|
||||
rovingContext.dispatch({
|
||||
type: Type.SetFocus,
|
||||
payload: {
|
||||
ref: rovingContext.state.refs[0],
|
||||
},
|
||||
});
|
||||
}, [query]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const activeSpace = SpaceStore.instance.activeSpaceRoom;
|
||||
const [spaceResults, spaceResultsLoading] = useSpaceResults(activeSpace, query);
|
||||
|
||||
|
|
Loading…
Reference in a new issue