Mantle Command Owned Behavior Migration Guide
Command no longer uses cmdk. It runs on mantle's listbox hook and filters in the DOM: a query writes hidden on each item that does not match and moves the matches into score order, so no item re-renders on a keystroke. The parts, their props, the command-score ranking, the keyboard, and useCommandState stay the same. Three things that a consumer can see change: the cmdk-* attributes are gone, a filtered item stays mounted, and groups now sort by their best match.
TL;DR: Replace each [cmdk-<part>] selector with [data-slot~=command-<part>], such as *:[[cmdk-group-heading]]:uppercase → *:[[data-slot~=command-group-heading]]:uppercase. In tests, query a filtered item by role (queryByRole("option", { name })), because a filtered item stays in the DOM with hidden. Remove asChild from Command.Root, Command.List, and Command.Group, where it always threw.
Codemod
From a mantle checkout:
In a project that installs @ngrok/mantle:
The codemod does step 2 in the string literals of each file that imports or re-exports @ngrok/mantle/command. It also rewrites the valued form, such as [cmdk-item=""]. A file that loads the palette with a dynamic import() is not covered; edit it by hand. It runs again safely. Pass --dry-run first, and run your formatter after. Do the other steps by hand: a selector in a .css file, a test query, and a choice about order are not syntax that a rule can read.
You are an agent migrating a codebase. Do this:
- Find every file that imports from
@ngrok/mantle/command, and every stylesheet or test that names acmdk-attribute or the--cmdk-list-heightvariable. - Replace each attribute selector with the part's
data-slot. The codemod does this step in TypeScript and TSX strings; do it by hand in CSS files.[cmdk-root]→[data-slot~=command][cmdk-input]→[data-slot~=command-input][cmdk-list]→[data-slot~=command-list][cmdk-group]→[data-slot~=command-group][cmdk-group-heading]→[data-slot~=command-group-heading][cmdk-group-items]→[data-slot~=command-group-items][cmdk-item]→[data-slot~=command-item][cmdk-separator]→[data-slot~=command-separator][cmdk-empty]→[data-slot~=command-empty]- A valued form, such as
[cmdk-item=""], moves the same way.
- Delete selectors for
[cmdk-label]and[cmdk-list-sizer], which have no part now.Command.Root'slabelsets the input'saria-label, andCommand.Listholds its children directly. Remove uses of--cmdk-list-height, which nothing sets now. - Replace
data-[disabled=false]anddata-[selected=false]onCommand.Item. An item hasdata-disabled="true"only when it is disabled, anddata-selected="true"only while it is active, so usenot-data-[disabled=true]:andnot-data-[selected=true]:. - In tests, a filtered item stays in the DOM with the
hiddenattribute.queryByText("Calendar")still finds it, so assertqueryByRole("option", { name: "Calendar" }), which skips a hidden element. An item no longer unmounts when the query filters it out, so its state and effects stay. - Remove
asChildfromCommand.Root,Command.List, andCommand.Group. cmdk threw at runtime for these three, so no working code passed it. - Check each palette that relies on the group order during a search. A group now moves above another group when its best item scores higher, as cmdk documents. To keep a fixed order, filter and rank the items yourself with
shouldFilter={false}. - After editing, run the project's formatter, linter, type checker, and tests.
Why own the behavior? cmdk re-rendered every item on each keystroke and scheduled its work through layout effects. It also imported Radix Dialog for its own
Command.Dialog, so an inline palette shipped a dialog it never rendered. The mantle palette filters in one pass over the DOM, and an inline palette is about 47% smaller (gzip).
Before → after
A heading style on a group
A test of a filtered item
Edge cases & gotchas
- The codemod skips a file that does not import
@ngrok/mantle/command, so a class string in a shared constant module needs a hand edit. [data-slot~=…]matches one token of the slot list, so a slot that anasChildparent joins in front still matches.Enterstill runsonSelectwithout a click, as in cmdk. AnasChildlink still navigates inonSelectonEnter.
How to verify
- Search for
cmdk-and--cmdk-list-height: no match should remain. - Run the tests that type into a palette, and check that each one asserts a filtered item by role.