-
-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: wxt cannot be used with the Dialog/DropdownMenu components of svelte shadcn/ui. #1340
Comments
You need to configure the teleport to put elements inside the shadow root. By default, teleports put elements outside the shadow root, so the CSS is not applied. https://wxt.dev/guide/resources/faq.html#my-component-library-doesn-t-work-in-content-scripts |
In fact, I have already configured it. Refer to the code, you can clone the repo to reproduce it. <script lang="ts">
import * as Dialog from '$lib/components/ui/dialog/index.js'
import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js'
const container = document
.querySelector('example-ui')
?.shadowRoot?.querySelector('body')!
</script>
<Dialog.Root>
<Dialog.Trigger>Open</Dialog.Trigger>
<Dialog.Content
portalProps={{
to: container,
}}
>
<Dialog.Header>
<Dialog.Title>Are you sure absolutely sure?</Dialog.Title>
<Dialog.Description>
<DropdownMenu.Root>
<DropdownMenu.Trigger>Open</DropdownMenu.Trigger>
<DropdownMenu.Content
portalProps={{
to: container,
}}
>
<DropdownMenu.Group>
<DropdownMenu.GroupHeading>My Account</DropdownMenu.GroupHeading>
<DropdownMenu.Separator />
<DropdownMenu.Item>Profile</DropdownMenu.Item>
<DropdownMenu.Item>Billing</DropdownMenu.Item>
<DropdownMenu.Item>Team</DropdownMenu.Item>
<DropdownMenu.Item>Subscription</DropdownMenu.Item>
</DropdownMenu.Group>
</DropdownMenu.Content>
</DropdownMenu.Root>
</Dialog.Description>
</Dialog.Header>
</Dialog.Content>
</Dialog.Root> |
Woops, sorry! This is a common question, so I reflexively responded with my standard response before fully reading your description. Checking your reproduction out now |
Strange, that seems to be a bug in svelte shadcn/ui, or it could be a bug in the lower-level bits-ui. I'll check the specific reason. Thank you for your help. |
Describe the bug
The Content Script uses the shadow DOM mode when injecting UI.
Kapture.2025-01-08.at.10.14.06.mp4
Code
Then use the Dialog component to pop up a window within the component, and use the DropdownMenu component to pop up a window within the Dialog component, but the pop-up of the DropdownMenu is not visible.
Code
Supplement, I'm actually not quite sure whether this belongs to a bug in svelte shadcn/ui or wxt, but I can't reproduce it using svelte shadcn/ui alone because I'm not very clear on how wxt's shadow DOM injects the UI.
Reproduction
https://github.com/rxliuli/shadcn-ui-wxt-error-demo
Steps to reproduce
pnpm i && pnpm dev
System Info
System: OS: macOS 15.2 CPU: (12) arm64 Apple M2 Max Memory: 6.72 GB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.12.1 - /usr/local/bin/node Yarn: 1.22.22 - /usr/local/bin/yarn npm: 10.5.0 - /usr/local/bin/npm pnpm: 9.15.0 - /usr/local/bin/pnpm bun: 1.1.6 - ~/.bun/bin/bun Watchman: 2024.10.07.00 - /opt/homebrew/bin/watchman Browsers: Brave Browser: 131.1.73.97 Chrome: 131.0.6778.205 Safari: 18.2
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: