mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-02 08:58:36 +00:00
fix(base): wrap dropdown label/items in group in message-scroller commands example (#11025)
DropdownMenuLabel renders Base UI's Menu.GroupLabel, which throws "MenuGroupContext is missing" (Base UI error #31) unless rendered inside a Menu.Group. Wrap the label and items in DropdownMenuGroup so the "Jump to..." menu opens without crashing. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuTrigger,
|
||||
@@ -137,22 +138,24 @@ function CommandMenu() {
|
||||
Jump to...
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" side="bottom" className="w-64">
|
||||
<DropdownMenuLabel>Conversations</DropdownMenuLabel>
|
||||
{userMessages.map((message) => (
|
||||
<DropdownMenuItem
|
||||
key={message.id}
|
||||
onSelect={() =>
|
||||
scrollToMessage(message.id, {
|
||||
align: "start",
|
||||
behavior: "smooth",
|
||||
})
|
||||
}
|
||||
>
|
||||
<span className="line-clamp-1 min-w-0">
|
||||
{getTrimmedMessageText(message)}
|
||||
</span>
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
<DropdownMenuGroup>
|
||||
<DropdownMenuLabel>Conversations</DropdownMenuLabel>
|
||||
{userMessages.map((message) => (
|
||||
<DropdownMenuItem
|
||||
key={message.id}
|
||||
onSelect={() =>
|
||||
scrollToMessage(message.id, {
|
||||
align: "start",
|
||||
behavior: "smooth",
|
||||
})
|
||||
}
|
||||
>
|
||||
<span className="line-clamp-1 min-w-0">
|
||||
{getTrimmedMessageText(message)}
|
||||
</span>
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</DropdownMenuGroup>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user