From 7ed135d9dff30644f93bba2d044265699b0d0928 Mon Sep 17 00:00:00 2001 From: jjagielka Date: Tue, 7 Nov 2023 06:14:35 +0100 Subject: [PATCH] middlewares as export (#1149) --- src/lib/utils/Popper.svelte | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/utils/Popper.svelte b/src/lib/utils/Popper.svelte index 0398c0f06..672e517d2 100644 --- a/src/lib/utils/Popper.svelte +++ b/src/lib/utils/Popper.svelte @@ -30,6 +30,8 @@ export let strategy: 'absolute' | 'fixed' = 'absolute'; export let open: boolean = false; export let yOnly: boolean = false; + // extra floating UI middleware list + export let middlewares: Middleware[] = [dom.flip(), dom.shift()]; const dispatch = createEventDispatcher(); @@ -81,8 +83,7 @@ top: 'bottom' }; - let middleware: (Middleware | null)[]; - $: middleware = [dom.flip(), dom.shift(), dom.offset(+offset), arrowEl && dom.arrow({ element: arrowEl, padding: 10 })]; + $: middleware = [...middlewares, dom.offset(+offset), arrowEl && dom.arrow({ element: arrowEl, padding: 10 })]; function updatePosition() { dom.computePosition(referenceEl, floatingEl, { placement, strategy, middleware }).then(({ x, y, middlewareData, placement, strategy }: ComputePositionReturn) => {