Repository navigation
fix(editor): run the slash command that was clicked - #3747
Merged
felipefreitag merged 2 commits intoOct 2, 2026
Merged
Conversation
The grouped slash command list numbered its rows by display position while the root resolved the selection against the unordered items array, so any category order other than the array order ran a different item's command. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Yyp6p2GWzkWKLsrxxJR1U
Contributor
|
@kaanisthatyou is attempting to deploy a commit to the resend Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 16d5ff7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Sort the items into category order in the root, after any filter, and only when the built-in list renders with no query. Before, the sort ran inside the default filter. A custom filterItems then made the arrow keys skip rows, and a custom children renderer got items in a new order. Add root tests for the arrow-key order with the default and a custom filter, Enter on the highlighted row, and the order children receive.
Member
|
Thanks for this. There was a issue where navigating with the keyboard on a custom list made the cursor jump around, I pushed a commit to fix it. |
commit: |
Contributor
Author
|
Thanks for catching that. I pulled 16d5ff7 and the editor unit tests pass locally (520/520). |
felipefreitag
approved these changes
Oct 2, 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.
Closes #3746.
Problem
With no query typed, the slash command menu can run a different item's command than the one clicked or highlighted. Using the docs' own custom commands example (an
Imageitem withcategory: 'Media'appended todefaultSlashCommands), the menu shows Text → Media → Layout, but clicking Image inserts a Button, and arrow keys highlight one row while Enter runs another.Root cause
The two sides numbered the rows differently.
ui/slash-command/command-list.tsxreorders the items for display:groupByCategorypulls the categories inCATEGORY_ORDERto the front, everything else follows in first-seen order. Each row then calledonSelect(flatIndex)— its position in the grouped display order — and highlighted itself with the same number.ui/slash-command/root.tsxresolves bothonSelectand the Enter handler againstsuggestionItemsRef.current[index], i.e. the original, unordered array, and the arrow keys walk that same array.As long as the array happens to be in
CATEGORY_ORDERthe two orders agree, which is why the built-in commands don't show it. Any other order — a custom category, a translated one, or a command appended at the end — shifts every row after the first group. With a query typed the list is rendered flat, so it works.Change
command-list.tsx:groupByCategorynow carries each item's index in the list the root holds, and the rows use that index for bothonSelectanddata-selected, instead of counting display positions. NoflatIndexcounter.command-list.tsx: exportsorderItemsByCategory, the same grouping flattened back into a list.root.tsx:defaultFilterItemsreturns the items in that display order when there is no query, so the arrow keys move down the list the way it is drawn instead of jumping between groups. With a query the list stays flat and ranked by score.What I deliberately left alone
CATEGORY_ORDERitself, and the choice to group only when there is no query.filterItemsstill controls its own order — the index bookkeeping keeps clicks correct whatever order it returns, including categories interleaved in the array.search.tsranking is untouched.Test
packages/editor/src/ui/slash-command/command-list.spec.tsxrenders the menu with[Text (Text), Divider (Layout), Image (Media)]— display order Text → Media → Layout, array order Text → Layout → Media — and covers the click index, the highlighted row andorderItemsByCategory.Before the fix, the new tests fail exactly the way the issue describes:
🤖 Generated with Claude Code
https://claude.ai/code/session_011Yyp6p2GWzkWKLsrxxJR1U
Summary by cubic
Fixes the slash command menu running a different command than clicked and arrow keys landing on the wrong row when categories display out of array order — for example, a custom
Imagecommand appended after the defaults could insert aButton.filterItems.childrenrenderers receiving items in array order.orderItemsByCategoryand adds unit tests for click, highlight, arrow-key, and renderer ordering.Written for commit 16d5ff7. Summary will update on new commits.