fix(ui): resolve CommandDialog crash on CMD/CTRL + J shortcut#4761
Merged
Conversation
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.
What is this PR about?
This PR fixes a critical regression introduced in v0.29.10 where users attempting to open the global search palette (via the
⌘JorCtrl+Jshortcut) would encounter a complete page crash resulting in a400error screen and a runtimeTypeError.The recent
shadcn/ui/ Tailwind v4 update (PR #4706) unintentionally broke the DOM structure and state context of theCommandDialogcomponent. This PR completely resolves the crash while strictly adhering to the new Tailwind v4 design patterns.How & Why
1. Fixed Radix UI Portal Rendering Crash (400 Error)
CommandDialogcomponent rewrite, the<DialogHeader>(which contains the<DialogTitle>and<DialogDescription>) was placed outside of the<DialogContent>wrapper. This invalid DOM structure broke the Radix UI accessibility constraints and portal rendering logic, causing Next.js to throw a fatal rendering error that triggered the_error.tsx400 page.<DialogHeader>back inside the<DialogContent>boundary where Radix UI expects it to be mounted.2. Fixed
cmdkSubscribeTypeError<Command>wrapper from insideCommandDialog. Because theSearchCommandcomponent renders sub-components (likeCommandInputandCommandList) as children of the dialog, these sub-components failed to find thecmdkcontext provider. Upon mounting, they attempted to.subscribe()to an undefined store, resulting in a fatal runtime JavaScript error.<Command>wrapper insideCommandDialogto properly initialize thecmdkstate store for its children.Intentional Optimizations & Architecture Decisions
CommandDialogrelied on a massive inline string of deeply nested CSS selectors (e.g.,[&_[cmdk-input]]:h-12) injected from the parent to override the styles of the command palette. This was brittle and broke component cohesion.CommandItem,CommandInput,CommandGroup) utilizing Tailwind v4's modernin-*contextual variants.in-data-[slot=dialog-content], these components now dynamically apply the larger paddings and icon sizes only when rendered inside a modal dialog. This perfectly preserves the compact styling of standard dropdowns and comboboxes (which usePopoverContent) elsewhere in the application, ensuring zero negative blast radius.Checklist
Before submitting this PR, please make sure that:
canarybranch.Issues related
closes #4756
Changes Verified
Yes
Screenshots
NA