Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/components/views/dialogs/spotlight/SpotlightDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,15 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
const setFilter = useCallback((filter: Filter | null) => {
setFilterInternal(filter);
inputRef.current?.focus();
scrollContainerRef.current?.scrollTo?.({ top: 0 });
const sc = scrollContainerRef.current;
if (sc) {
// Prefer scrollTo when available (supports smooth options), otherwise fallback to scrollTop.
if (typeof (sc as any).scrollTo === "function") {
(sc as any).scrollTo({ top: 0 });
} else {
(sc as HTMLDivElement).scrollTop = 0;
}
}
}, []);
const memberComparator = useMemo(() => {
const activityScores = buildActivityScores(cli);
Expand Down Expand Up @@ -1120,6 +1128,23 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
}

const onDialogKeyDown = (ev: KeyboardEvent | React.KeyboardEvent): void => {
const key = (ev as KeyboardEvent).key;
// handle PageUp / PageDown to scroll the results container by one page
if (key === "PageDown" || key === "PageUp") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be using the keybinding stack as below

ev.stopPropagation();
ev.preventDefault();
const sc = scrollContainerRef.current;
if (sc) {
const page = sc.clientHeight - 40; // small overlap to keep context
if (typeof (sc as any).scrollBy === "function") {
(sc as any).scrollBy({ top: key === "PageDown" ? page : -page, behavior: "smooth" });
} else {
sc.scrollTop = Math.max(0, Math.min(sc.scrollHeight - sc.clientHeight, sc.scrollTop + (key === "PageDown" ? page : -page)));
}
}
return;
}

const navigationAction = getKeyBindingsManager().getNavigationAction(ev);
switch (navigationAction) {
case KeyBindingAction.FilterRooms:
Expand Down
Loading