@melt-ui/svelte
Advanced tools
Comparing version 0.41.2 to 0.41.3
@@ -60,7 +60,2 @@ import { addMeltEventListener, builder, createElHelpers, derivedVisible, effect, generateId, getPortalDestination, isBrowser, isHTMLElement, kbd, noop, omit, overridable, removeScroll, styleToString, toWritableStores, } from '../../internal/helpers/index.js'; | ||
action: (node) => { | ||
/** | ||
* We need to get the parent portal before the menu is opened, | ||
* otherwise the parent will have been moved to the body, and | ||
* will no longer be an ancestor of this node. | ||
*/ | ||
let unsubPopper = noop; | ||
@@ -79,24 +74,22 @@ const unsubDerived = effect([ | ||
return; | ||
tick().then(() => { | ||
const popper = usePopper(node, { | ||
anchorElement: $activeTrigger, | ||
open, | ||
options: { | ||
floating: $positioning, | ||
focusTrap: $disableFocusTrap ? null : undefined, | ||
clickOutside: $closeOnOutsideClick ? undefined : null, | ||
escapeKeydown: $closeOnEscape | ||
? { | ||
handler: () => { | ||
handleClose(); | ||
}, | ||
} | ||
: null, | ||
portal: getPortalDestination(node, $portal), | ||
}, | ||
}); | ||
if (popper && popper.destroy) { | ||
unsubPopper = popper.destroy; | ||
} | ||
const popper = usePopper(node, { | ||
anchorElement: $activeTrigger, | ||
open, | ||
options: { | ||
floating: $positioning, | ||
focusTrap: $disableFocusTrap ? null : undefined, | ||
clickOutside: $closeOnOutsideClick ? undefined : null, | ||
escapeKeydown: $closeOnEscape | ||
? { | ||
handler: () => { | ||
handleClose(); | ||
}, | ||
} | ||
: null, | ||
portal: getPortalDestination(node, $portal), | ||
}, | ||
}); | ||
if (popper && popper.destroy) { | ||
unsubPopper = popper.destroy; | ||
} | ||
}); | ||
@@ -111,4 +104,9 @@ return { | ||
}); | ||
function toggleOpen() { | ||
open.update((prev) => !prev); | ||
function toggleOpen(triggerEl) { | ||
open.update((prev) => { | ||
return !prev; | ||
}); | ||
if (triggerEl) { | ||
activeTrigger.set(triggerEl); | ||
} | ||
} | ||
@@ -129,4 +127,3 @@ const trigger = builder(name('trigger'), { | ||
const unsub = executeCallbacks(addMeltEventListener(node, 'click', () => { | ||
activeTrigger.set(node); | ||
toggleOpen(); | ||
toggleOpen(node); | ||
}), addMeltEventListener(node, 'keydown', (e) => { | ||
@@ -136,4 +133,3 @@ if (e.key !== kbd.ENTER && e.key !== kbd.SPACE) | ||
e.preventDefault(); | ||
activeTrigger.set(node); | ||
toggleOpen(); | ||
toggleOpen(node); | ||
})); | ||
@@ -140,0 +136,0 @@ return { |
{ | ||
"name": "@melt-ui/svelte", | ||
"version": "0.41.2", | ||
"version": "0.41.3", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "exports": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
593162
13734