fix(cmdk): Omit empty groups and reset scroll on query change#112325
Merged
JonasBa merged 1 commit intojb/cmdk/jsx-pocfrom Apr 9, 2026
Merged
fix(cmdk): Omit empty groups and reset scroll on query change#112325JonasBa merged 1 commit intojb/cmdk/jsx-pocfrom
JonasBa merged 1 commit intojb/cmdk/jsx-pocfrom
Conversation
Empty CMDKGroups (no registered children) were appearing as clickable action items in browse mode. Filter them out in flattenActions so only groups with children or executable actions are shown. Also reset the results list scroll position to the top whenever the search query changes. The actual scroll element is the inner virtualizer container inside ListBox, not the outer ResultsList wrapper, so expose a scrollContainerRef prop on ListBox and wire it up in CommandPalette's onChange handler. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
TkDodo
approved these changes
Apr 7, 2026
rbro112
approved these changes
Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small fixes for the JSX-powered command palette.
Empty groups are now omitted from the list. A
CMDKGroupthat renders no children ends up with zero registered nodes in the collection. In browse mode,flattenActionswas treating such nodes as leaf actions and showing them. These are headless section headers with nothing to show — they should be invisible. The fix skips any node that has no children and no executable action (to/onAction).Scroll resets to the top when the query changes. Typing a new search query now scrolls the results list back to the top. The tricky part:
ResultsListis not the actual scroll element —ListBoxcreates its own innerdivthat it hands to TanStack Virtual as the scroll container. The fix adds ascrollContainerRefprop toListBoxthat gets merged into that inner container's refs, then wires it up in theonChangehandler.Stacked on #112262.