When using el-dropdown / el-menu inside a SvelteKit application, the dropdown menu opens at the top-left corner of the viewport (position: absolute; left: 0; top: 0) instead of below the trigger button.
The bug only occurs when the page containing the dropdown is reached via client-side navigation (e.g., clicking a <a href> link with SvelteKit's router). When the same page is server-side rendered (direct URL access or hard reload), the dropdown positions correctly.
Steps to Reproduce
- Create a SvelteKit application with @tailwindplus/elements installed
- Create two pages: a home page with a link, and a second page with an el-dropdown component
- Load the second page directly via URL → dropdown positions correctly ✅
- Navigate back to the home page, then click the link to the second page (client-side navigation) → click the dropdown trigger → menu appears at the top-left corner ❌
Minimal Reproduction
<!-- src/routes/entries/+page.svelte -->
<el-dropdown class="relative inline-block">
<button type="button">Open menu</button>
<el-menu
anchor="bottom end"
popover
class="w-44 origin-top-right rounded-md bg-white py-1 shadow-lg ..."
>
<button type="button">Option 1</button>
<button type="button">Option 2</button>
</el-menu>
</el-dropdown>
Expected Behavior
The el-menu popover should appear anchored to the bottom-end of the trigger button, regardless of how the page was navigated to.
Actual Behavior
On client-side navigation, the el-menu appears at approximately left: 0; top: 0 (top-left corner of the viewport).
Environment
- Framework: SvelteKit (Svelte 5)
- @tailwindplus/elements version: 1.0.22
- Browser: Chrome (latest)
- Navigation type that fails: SvelteKit client-side routing (goto() / link navigation)
- Navigation type that works: Direct URL / hard reload (SSR)
Analysis
The positioning is computed inside the beforetoggle event handler via floating-ui with strategy: "absolute". On client-side navigation in SvelteKit, the floating-ui computation appears to resolve coordinates as (0, 0), causing the final Object.assign(e.style, { position: "absolute", left: "0px", top: "0px" }) to place the popover at the top-left corner.
A potential workaround of using anchor-strategy="fixed" on the el-menu element has not been confirmed to resolve the issue.
Possible Root Cause
The issue likely relates to a timing or context difference between how the Popover API and floating-ui resolve element geometry when the component is mounted via SvelteKit's client-side navigation vs. a full server-side render. The el-dropdown web component's connectedCallback → queueMicrotask(mount) lifecycle may not have fully established the anchor positioning context by the time the first interaction occurs.
Workaround
None confirmed at this time.
When using el-dropdown / el-menu inside a SvelteKit application, the dropdown menu opens at the top-left corner of the viewport (position: absolute; left: 0; top: 0) instead of below the trigger button.
The bug only occurs when the page containing the dropdown is reached via client-side navigation (e.g., clicking a
<a href>link with SvelteKit's router). When the same page is server-side rendered (direct URL access or hard reload), the dropdown positions correctly.Steps to Reproduce
Minimal Reproduction
Expected Behavior
The el-menu popover should appear anchored to the bottom-end of the trigger button, regardless of how the page was navigated to.
Actual Behavior
On client-side navigation, the el-menu appears at approximately left: 0; top: 0 (top-left corner of the viewport).
Environment
Analysis
The positioning is computed inside the beforetoggle event handler via floating-ui with strategy: "absolute". On client-side navigation in SvelteKit, the floating-ui computation appears to resolve coordinates as (0, 0), causing the final Object.assign(e.style, { position: "absolute", left: "0px", top: "0px" }) to place the popover at the top-left corner.
A potential workaround of using anchor-strategy="fixed" on the el-menu element has not been confirmed to resolve the issue.
Possible Root Cause
The issue likely relates to a timing or context difference between how the Popover API and floating-ui resolve element geometry when the component is mounted via SvelteKit's client-side navigation vs. a full server-side render. The el-dropdown web component's connectedCallback → queueMicrotask(mount) lifecycle may not have fully established the anchor positioning context by the time the first interaction occurs.
Workaround
None confirmed at this time.