Skip to content

Commit

Permalink
Fixes #4988
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBessa committed Oct 6, 2023
1 parent 9c6ba80 commit 2ee3b0b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/mantine-spotlight/src/spotlight.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ export function setListId(id: string, store: SpotlightStore) {

export function selectAction(index: number, store: SpotlightStore): number {
const state = store.getState();
const actionsList = document.getElementById(state.listId)!;
const selected = actionsList.querySelector<HTMLButtonElement>('[data-selected]');
const actions = actionsList.querySelectorAll<HTMLButtonElement>('[data-action]');
const actionsList = document.getElementById(state.listId);
const selected = actionsList?.querySelector<HTMLButtonElement>('[data-selected]');
const actions = actionsList?.querySelectorAll<HTMLButtonElement>('[data-action]') ?? [];
const nextIndex = index === -1 ? actions.length - 1 : index === actions.length ? 0 : index;

const selectedIndex = clamp(nextIndex, 0, actions.length - 1);
Expand Down

0 comments on commit 2ee3b0b

Please sign in to comment.