timc1/kbar

useMatches rootActionId and results are out of sync

Closed this issue · 1 comments

Due to throttling, when changing rootActionId, the results and rootActionId returned by useMatches is out of sync.

Added this line to the example App.jsx on line 152:
console.log(rootActionId, results.length);

Steps to reproduce:

  1. Press CMD+?
  2. Press backspace
  3. Console outputs:
y7joo53 18
App.tsx:128 y7joo53 18
App.tsx:128 undefined 18
App.tsx:128 undefined 10

You cannot really see the visual implications of it in the demo very well, as the structure is pretty similar for the two views, but for cases where the rendered content looks quite different in these two views, there's visual jumpiness.

Expected behaviour:
Throttling should only apply to user input. When changing rootActionId, the changes should be immediate. Otherwise KbarResults.tsx rootActionId is also out of sync, as it uses the unthrottled value from useKBar, rather than useMatches, so you end up with an unsynced view where results and the rest of the UI don't correspond to each other.

Hey! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.