mantinedev / mantine

A fully featured React components library
https://mantine.dev
MIT License
26.79k stars 1.9k forks source link

[@mantine/spotlight] createSpotlight : Reset the selected index when using the toggle function #6842

Closed maclementED closed 1 month ago

maclementED commented 1 month ago

Bug

When using spotlight.toggle instead of spotlight.open, using down arrow key will jump the first item.

How to reproduce

import { spotlight } from '@mantine/spotlight';

...

spotlight.open() // Will have selected:-1

spotlight.close()

spotlight.toggle() // Will have selected: 0 instead of -1. Using Down Arrow Key will skip the first item

Fix

Set the selected to -1 when you open the spotlight using toggle

rtivital commented 1 month ago

Please fix errors

rtivital commented 1 month ago

Thanks!