Skip to content

Commit e565592

Browse files
committed
[fix] add tick before init autoUpdate
1 parent 38e3c74 commit e565592

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "svelte-floating-ui",
33
"description": "Svelte actions for working with floating ui",
4-
"version": "1.4.6",
4+
"version": "1.5.2",
55
"license": "MIT",
66
"main": "./index.js",
77
"svelte": "./index.js",

src/lib/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { autoUpdate as _autoUpdate, computePosition, type MiddlewareArguments }
77
import type { Options } from "@floating-ui/dom/src/autoUpdate";
88
import type { Readable, Writable } from "svelte/store";
99
import { get } from "svelte/store";
10-
import { onDestroy } from 'svelte';
10+
import { onDestroy, tick } from 'svelte';
1111

1212
export type ComputeConfig = Partial<ComputePositionConfig> & {
1313
onComputed?: (computed: ComputePositionReturn) => void
@@ -77,7 +77,9 @@ export function createFloatingActions(initOptions?: ComputeConfig): [ReferenceAc
7777
const initAutoUpdate = ({autoUpdate} = options || {}):typeof autoUpdateDestroy => {
7878
destroyAutoUpdate()
7979
if(autoUpdate !== false) {
80-
return _autoUpdate(referenceElement, floatingElement, () => updatePosition(options), (autoUpdate === true ? {} : autoUpdate));
80+
tick().then(() => {
81+
return _autoUpdate(referenceElement, floatingElement, () => updatePosition(options), (autoUpdate === true ? {} : autoUpdate));
82+
})
8183
}
8284
return
8385
}

0 commit comments

Comments
 (0)