Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Tweak spotlight roving behaviour to reset when changing query (#7656)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Jan 27, 2022
1 parent b77d31b commit 5144637
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/views/dialogs/SpotlightDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import React, {
useCallback,
useContext,
useEffect,
useLayoutEffect,
useMemo,
useState,
} from "react";
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 5144637

Please sign in to comment.