solid-dismiss
Advanced tools
Comparing version 1.6.6 to 1.6.7
@@ -23,3 +23,3 @@ import { isServer } from "solid-js/web"; | ||
const modal = props.modal || false; | ||
const { id, menuButton, menuPopup, focusElementOnClose, focusElementOnOpen = modal ? "menuPopup" : undefined, cursorKeys = false, closeWhenMenuButtonIsTabbed = false, closeWhenMenuButtonIsClicked = true, closeWhenScrolling = false, closeWhenDocumentBlurs = false, closeWhenOverlayClicked = true, closeWhenEscapeKeyIsPressed = true, overlay = modal, overlayElement = modal, trapFocus = modal, removeScrollbar = modal, enableLastFocusSentinel = false, mount = modal ? "body" : undefined, | ||
const { id, menuButton, menuPopup, focusElementOnClose, focusElementOnOpen = modal ? "menuPopup" : undefined, focusMenuButtonOnMouseDown = true, cursorKeys = false, closeWhenMenuButtonIsTabbed = false, closeWhenMenuButtonIsClicked = true, closeWhenScrolling = false, closeWhenDocumentBlurs = false, closeWhenOverlayClicked = true, closeWhenEscapeKeyIsPressed = true, overlay = modal, overlayElement = modal, trapFocus = modal, removeScrollbar = modal, enableLastFocusSentinel = false, mount = modal ? "body" : undefined, | ||
// stopComponentEventPropagation = false, | ||
@@ -39,2 +39,3 @@ show = false, onToggleScrollbar, onOpen, deadMenuButton, ignoreMenuPopupWhenTabbing, mountedPopupsSafeList, } = props; | ||
focusElementOnClose, | ||
focusMenuButtonOnMouseDown, | ||
deadMenuButton, | ||
@@ -41,0 +42,0 @@ focusElementOnOpen, |
@@ -85,9 +85,13 @@ import { dismissStack } from "../global/dismissStack"; | ||
export const onMouseDownMenuButton = (state, e) => { | ||
const { focusMenuButtonOnMouseDown } = state; | ||
const menuBtnEl = e.currentTarget; | ||
state.menuBtnMouseDownFired = true; | ||
menuBtnEl.addEventListener("click", state.onClickMenuButtonRef); | ||
menuBtnEl.addEventListener("blur", state.onBlurMenuButtonRef); | ||
requestAnimationFrame(() => { | ||
menuBtnEl.focus(); | ||
}); | ||
// if `false`, enables switching focus from menuButton to menuPopup input element while keeping virtual keyboard opened in iOS. However end-user must also provide additional logic to fire inside menuButton onclick for behavior to work. | ||
if (focusMenuButtonOnMouseDown) { | ||
menuBtnEl.addEventListener("blur", state.onBlurMenuButtonRef); | ||
requestAnimationFrame(() => { | ||
menuBtnEl.focus(); | ||
}); | ||
} | ||
}; | ||
@@ -94,0 +98,0 @@ // TODO: ? |
@@ -11,2 +11,4 @@ import { getMenuButton } from "../local/menuButton"; | ||
if (type === "focusElementOnOpen") { | ||
if (inputElement === "none") | ||
return null; | ||
if (inputElement === "firstChild") { | ||
@@ -13,0 +15,0 @@ return getNextTabbableElement({ |
@@ -71,7 +71,7 @@ import { Accessor, JSX, ParentComponent } from "solid-js"; | ||
* | ||
* *CSS string queried from menuPopup element, or if string value is `"menuPopup"` uses menuPopup element, or if string value is `"firstChild"` uses first tabbable element inside menuPopup. | ||
* *CSS string queried from menuPopup element. If string value is `"menuPopup"` uses menuPopup element. `"firstChild"` uses first tabbable element inside menuPopup. `"none"` focus remains on `"menuButton"`, even if `Dismiss.modal` is true. | ||
* | ||
* @defaultValue focus remains on `"menuButton"`. But if there's no menu button, focus remains on document's activeElement. | ||
*/ | ||
focusElementOnOpen?: "menuPopup" | "firstChild" | JSX.Element | (() => JSX.Element); | ||
focusElementOnOpen?: "menuPopup" | "firstChild" | "none" | JSX.Element | (() => JSX.Element); | ||
/** | ||
@@ -138,2 +138,8 @@ * | ||
/** | ||
* @default `true` | ||
* | ||
* Set to `false` if you want to switch focus from menuButton to menuPopup input element while keeping virtual keyboard opened in iOS. However end-user must also provide additional logic to fire inside menuButton onclick for behavior to work. | ||
*/ | ||
focusMenuButtonOnMouseDown?: boolean; | ||
/** | ||
* When `true`, clicking or focusing on menuButton doesn't toggle menuPopup. However the menuButton is still used as reference from `focusElementOnClose` | ||
@@ -140,0 +146,0 @@ * |
{ | ||
"name": "solid-dismiss", | ||
"version": "1.6.6", | ||
"version": "1.6.7", | ||
"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 too big to display
Sorry, the diff of this file is not supported yet
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
347525
4686