ITADN

Dropdown menu content is forced to trigger width

#2733Closedmaxffarrell 创建于 2026-06-05
M
maxffarrellcommented
## Description The docs `Copy Page` dropdown wraps menu item labels. `DocsCopyPage` uses `DropdownMenu`, and the Svelte dropdown content wrapper currently forces all dropdown menu content to the trigger width. ## Evidence `DocsCopyPage` renders the desktop menu with `DropdownMenu.Content` and `DropdownMenu.Item`, not `Select.Item`: ```svelte <DropdownMenu.Content align="end" class="shadow-none"> {#each Object.entries(menuItems) as [key, value] (key)} <DropdownMenu.Item> {#snippet child({ props })} {@render value({ props })} {/snippet} </DropdownMenu.Item> {/each} </DropdownMenu.Content> ``` Source: [`docs/src/lib/components/docs-copy-page.svelte#L142-L150`](https://github.com/huntabyte/shadcn-svelte/blob/main/docs/src/lib/components/docs-copy-page.svelte#L142-L150) The local dropdown content component applies `w-(--bits-dropdown-menu-anchor-width)` by default: ```svelte "cn-dropdown-menu-content cn-dropdown-menu-content-logical cn-menu-target cn-menu-translucent z-50 w-(--bits-dropdown-menu-anchor-width) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden" ``` Source: [`docs/src/lib/registry/ui/dropdown-menu/dropdown-menu-content.svelte#L25-L27`](https://github.com/huntabyte/shadcn-svelte/blob/main/docs/src/lib/registry/ui/dropdown-menu/dropdown-menu-content.svelte#L25-L27) For the `Copy Page` menu, the dropdown trigger is only the small chevron button, so forcing content to the anchor width constrains the menu and allows labels like `View as Markdown` to wrap. Upstream shadcn/ui does not force dropdown content to the trigger width by default. It uses `min-w-[8rem]` and lets content size naturally: ```tsx "z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md ..." ``` Source: [`apps/v4/registry/bases/radix/ui/dropdown-menu.tsx#L41-L48`](https://github.com/shadcn-ui/ui/blob/main/apps/v4/registry/bases/radix/ui/dropdown-menu.tsx#L41-L48) ## Expected behavior Default `DropdownMenu.Content` should match upstream behavior: provide a minimum width but not force content to the trigger width. Call sites that need anchor-width behavior can still opt in with `class="w-(--bits-dropdown-menu-anchor-width)"`, as several sidebar examples already do.
关闭于 2026-06-05 2 条评论