formaat-design / reshaped

Community repository for storing examples, reporting issues and tracking roadmap
https://reshaped.so
97 stars 3 forks source link

Keyboard navigation in Autocomplete component not working with dynamic data #172

Closed Madhavkabra closed 10 months ago

Madhavkabra commented 10 months ago

When using Autocomplete component with dynamic options in suspense, the keyboard navigation breaks.

Screenshot (69)

You can see, we do not get focus on the first item This problem does not happen when having a static list of options

Also, tried replicating this issue on stackblitz and codesandbox, but got "addHotKeys is not a function" error. Stackblitz -> https://stackblitz.com/edit/stackblitz-starters-zfggn9?file=app%2Fpage.tsx Codesandbox -> https://codesandbox.io/p/sandbox/gracious-wright-hv5thr

blvdmitry commented 10 months ago

Thanks for reporting, I have an idea why that might be happening, adding it to the upcoming release as well

blvdmitry commented 10 months ago

I thought I knew why this is happening but still struggling reproducing this. I've tried a few options with async loading of the items but it still works.

A few notes:

blvdmitry commented 10 months ago

I think I got closer. I can get the reproduction of a use case when the first item doesn't get highlighted. Does pressing an arrow key still highlights it in your case as well?

blvdmitry commented 10 months ago

Got it working with this example, where I simulate data fetching every time I'm changing the input. Will be out with the next patch after I figure out a better approach for using framework links together with tabs :)

https://github.com/formaat-design/reshaped/assets/887379/83f384e0-aca6-482a-9a3f-a204bae98227

Madhavkabra commented 10 months ago

Awesome @blvdmitry. I will try to find some more time to help you reproduce them next time.