solid-dismiss
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -909,4 +909,5 @@ import { insert, template, delegateEvents, addEventListener, effect, setAttribute, classList, createComponent, mergeProps } from 'solid-js/web'; | ||
e.preventDefault(); | ||
const el = getNextTabbableElement({ | ||
from: focusSentinelBeforeEl | ||
let el = getNextTabbableElement({ | ||
from: focusSentinelBeforeEl, | ||
stopAtElement: containerEl | ||
}); | ||
@@ -920,2 +921,13 @@ | ||
if (!el) { | ||
setOpen(false); | ||
el = getNextTabbableElement({ | ||
from: focusSentinelBeforeEl | ||
}); | ||
if (el) { | ||
el.focus(); | ||
} | ||
} | ||
menuBtnEl.removeEventListener("keydown", onKeydownMenuButtonRef); | ||
@@ -1614,2 +1626,16 @@ menuBtnEl.removeEventListener("blur", onBlurMenuButtonRef); | ||
}); | ||
if (show && mount) { | ||
CreatePortal({ | ||
mount: typeof mount === "string" ? document.querySelector(mount) : mount, | ||
popupChildren: render(props.children), | ||
overlayChildren: overlayElement ? renderOverlay() : null, | ||
marker, | ||
onCreate: (mount, container) => { | ||
mountEl = mount; | ||
containerEl = container; | ||
} | ||
}); | ||
} | ||
createComputed(on(() => !!props.open(), (open, prevOpen) => { | ||
@@ -1626,3 +1652,3 @@ if (open === prevOpen) return; | ||
if (!mount) return; | ||
if (!mount || show) return; | ||
@@ -1712,3 +1738,3 @@ if (open) { | ||
if (mount && mountEl && !exitRunning) { | ||
if (!show && mount && mountEl && !exitRunning) { | ||
exitTransition("popup", containerEl?.firstElementChild); | ||
@@ -1715,0 +1741,0 @@ exitTransition("overlay", state.overlayEl); |
@@ -305,2 +305,14 @@ import "./browserInfo"; | ||
}); | ||
if (show && mount) { | ||
CreatePortal({ | ||
mount: typeof mount === "string" ? document.querySelector(mount) : mount, | ||
popupChildren: render(props.children), | ||
overlayChildren: overlayElement ? renderOverlay() : null, | ||
marker, | ||
onCreate: (mount, container) => { | ||
mountEl = mount; | ||
containerEl = container; | ||
}, | ||
}); | ||
} | ||
createComputed(on(() => !!props.open(), (open, prevOpen) => { | ||
@@ -315,3 +327,3 @@ if (open === prevOpen) | ||
} | ||
if (!mount) | ||
if (!mount || show) | ||
return; | ||
@@ -391,3 +403,3 @@ if (open) { | ||
removeGlobalEvents(); | ||
if (mount && mountEl && !exitRunning) { | ||
if (!show && mount && mountEl && !exitRunning) { | ||
exitTransition("popup", containerEl?.firstElementChild); | ||
@@ -394,0 +406,0 @@ exitTransition("overlay", state.overlayEl); |
@@ -120,3 +120,6 @@ import { dismissStack } from "./dismissStack"; | ||
e.preventDefault(); | ||
const el = getNextTabbableElement({ from: focusSentinelBeforeEl }); | ||
let el = getNextTabbableElement({ | ||
from: focusSentinelBeforeEl, | ||
stopAtElement: containerEl, | ||
}); | ||
if (el) { | ||
@@ -128,2 +131,11 @@ el.focus(); | ||
} | ||
if (!el) { | ||
setOpen(false); | ||
el = getNextTabbableElement({ | ||
from: focusSentinelBeforeEl, | ||
}); | ||
if (el) { | ||
el.focus(); | ||
} | ||
} | ||
menuBtnEl.removeEventListener("keydown", onKeydownMenuButtonRef); | ||
@@ -130,0 +142,0 @@ menuBtnEl.removeEventListener("blur", onBlurMenuButtonRef); |
{ | ||
"name": "solid-dismiss", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"homepage": "https://aquaductape.github.io/solid-dismiss/", | ||
@@ -5,0 +5,0 @@ "description": "Handles \"click outside\" behavior for popup menu. Closing is triggered by click/focus outside of popup element or pressing \"Escape\" key.", |
Sorry, the diff of this file is not supported yet
259249
3564