From 8d203fa801d8f00f2f4dbfe3f4668f82e1a6bb7f Mon Sep 17 00:00:00 2001 From: Hunter Johnston Date: Wed, 18 Feb 2026 14:05:03 -0500 Subject: [PATCH] fix(FloatingContent): watch deps --- .changeset/long-teeth-worry.md | 5 +++++ .../floating-layer/use-floating-layer.svelte.ts | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .changeset/long-teeth-worry.md diff --git a/.changeset/long-teeth-worry.md b/.changeset/long-teeth-worry.md new file mode 100644 index 000000000..3f1d3899c --- /dev/null +++ b/.changeset/long-teeth-worry.md @@ -0,0 +1,5 @@ +--- +"bits-ui": patch +--- + +fix(FloatingContent): watch deps diff --git a/packages/bits-ui/src/lib/bits/utilities/floating-layer/use-floating-layer.svelte.ts b/packages/bits-ui/src/lib/bits/utilities/floating-layer/use-floating-layer.svelte.ts index d0819a4e2..d6453a404 100644 --- a/packages/bits-ui/src/lib/bits/utilities/floating-layer/use-floating-layer.svelte.ts +++ b/packages/bits-ui/src/lib/bits/utilities/floating-layer/use-floating-layer.svelte.ts @@ -293,13 +293,14 @@ export class FloatingContentState { }); watch( - () => this.contentRef.current, - (contentNode) => { - if (!contentNode || !this.opts.enabled.current) return; + [() => this.contentRef.current, () => this.opts.enabled.current], + ([contentNode, enabled]) => { + if (!contentNode || !enabled) return; const win = getWindow(contentNode); const rafId = win.requestAnimationFrame(() => { // avoid applying stale values when refs change quickly - if (this.contentRef.current !== contentNode || !this.opts.enabled.current) return; + if (this.contentRef.current !== contentNode || !this.opts.enabled.current) + return; const zIndex = win.getComputedStyle(contentNode).zIndex; if (zIndex !== this.contentZIndex) { this.contentZIndex = zIndex;