@mirohq/design-system-use-press
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -189,2 +189,3 @@ 'use strict'; | ||
if (state.target instanceof HTMLElement && state.target.contains(target) && (isHTMLAnchorLink(state.target) || state.target.getAttribute("role") === "link")) { | ||
state.ignoreClickAfterPress = true; | ||
state.target.click(); | ||
@@ -264,7 +265,27 @@ } | ||
const role = element.getAttribute("role"); | ||
return isEnterOrSpaceEvent(event) && // Inputs | ||
!(element instanceof HTMLInputElement && !isValidInputKey(element, key) || element instanceof HTMLTextAreaElement || element.isContentEditable) && // A link with a valid href should be handled natively, | ||
// unless it also has role='button' and was triggered using Space. | ||
(!isHTMLAnchorLink(element) || role === "button" && key !== "Enter") && // An element with role='link' should only trigger with Enter key | ||
!(role === "link" && key !== "Enter"); | ||
if (!isEnterOrSpaceEvent(event)) { | ||
return false; | ||
} | ||
const isLink = isHTMLAnchorLink(element) || role === "link"; | ||
if (isLink && key === "Enter") { | ||
return true; | ||
} | ||
if (element.tagName === "A") { | ||
if (role === "button" && key === " ") { | ||
return true; | ||
} | ||
return false; | ||
} | ||
const isButton = role === "button" || element.tagName === "BUTTON"; | ||
if (isButton) { | ||
return true; | ||
} | ||
const isInput = element instanceof HTMLInputElement; | ||
if (isInput && isValidInputKey(element, key) && key === " ") { | ||
return true; | ||
} | ||
if (!isLink && !isButton && !isInput) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
@@ -271,0 +292,0 @@ |
@@ -185,2 +185,3 @@ import { useRef, useState, useEffect } from 'react'; | ||
if (state.target instanceof HTMLElement && state.target.contains(target) && (isHTMLAnchorLink(state.target) || state.target.getAttribute("role") === "link")) { | ||
state.ignoreClickAfterPress = true; | ||
state.target.click(); | ||
@@ -260,7 +261,27 @@ } | ||
const role = element.getAttribute("role"); | ||
return isEnterOrSpaceEvent(event) && // Inputs | ||
!(element instanceof HTMLInputElement && !isValidInputKey(element, key) || element instanceof HTMLTextAreaElement || element.isContentEditable) && // A link with a valid href should be handled natively, | ||
// unless it also has role='button' and was triggered using Space. | ||
(!isHTMLAnchorLink(element) || role === "button" && key !== "Enter") && // An element with role='link' should only trigger with Enter key | ||
!(role === "link" && key !== "Enter"); | ||
if (!isEnterOrSpaceEvent(event)) { | ||
return false; | ||
} | ||
const isLink = isHTMLAnchorLink(element) || role === "link"; | ||
if (isLink && key === "Enter") { | ||
return true; | ||
} | ||
if (element.tagName === "A") { | ||
if (role === "button" && key === " ") { | ||
return true; | ||
} | ||
return false; | ||
} | ||
const isButton = role === "button" || element.tagName === "BUTTON"; | ||
if (isButton) { | ||
return true; | ||
} | ||
const isInput = element instanceof HTMLInputElement; | ||
if (isInput && isValidInputKey(element, key) && key === " ") { | ||
return true; | ||
} | ||
if (!isLink && !isButton && !isInput) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
@@ -267,0 +288,0 @@ |
{ | ||
"name": "@mirohq/design-system-use-press", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "Miro", |
Sorry, the diff of this file is not supported yet
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
166508
1668