@mirohq/design-system-use-press
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -183,3 +183,3 @@ 'use strict'; | ||
if (state.isPressed && state.target != null && isValidKeyboardEvent(e, state.target)) { | ||
if (shouldPreventDefaultKeyboard(e.target, e.key)) { | ||
if (shouldPreventDefaultKeyboard(e.target)) { | ||
e.preventDefault(); | ||
@@ -209,9 +209,9 @@ } | ||
} | ||
if (e.repeat) { | ||
return; | ||
} | ||
if (isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && e.currentTarget.contains(e.target)) { | ||
if (shouldPreventDefaultKeyboard(e.target, e.key)) { | ||
if (shouldPreventDefaultKeyboard(e.target)) { | ||
e.preventDefault(); | ||
} | ||
if (e.repeat) { | ||
return; | ||
} | ||
handleFocus({ | ||
@@ -257,11 +257,3 @@ target: e.currentTarget, | ||
]); | ||
const shouldPreventDefaultKeyboard = (target, key) => { | ||
if (target instanceof HTMLInputElement) { | ||
return !isValidInputKey(target, key); | ||
} | ||
if (target instanceof HTMLButtonElement) { | ||
return target.type !== "submit"; | ||
} | ||
return true; | ||
}; | ||
const shouldPreventDefaultKeyboard = (target) => !(target instanceof HTMLInputElement || target instanceof HTMLButtonElement); | ||
const isHTMLAnchorLink = (target) => target.tagName === "A" && target.hasAttribute("href"); | ||
@@ -268,0 +260,0 @@ const isValidInputKey = (target, key) => ( |
@@ -179,3 +179,3 @@ import { useRef, useState, useEffect } from 'react'; | ||
if (state.isPressed && state.target != null && isValidKeyboardEvent(e, state.target)) { | ||
if (shouldPreventDefaultKeyboard(e.target, e.key)) { | ||
if (shouldPreventDefaultKeyboard(e.target)) { | ||
e.preventDefault(); | ||
@@ -205,9 +205,9 @@ } | ||
} | ||
if (e.repeat) { | ||
return; | ||
} | ||
if (isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && e.currentTarget.contains(e.target)) { | ||
if (shouldPreventDefaultKeyboard(e.target, e.key)) { | ||
if (shouldPreventDefaultKeyboard(e.target)) { | ||
e.preventDefault(); | ||
} | ||
if (e.repeat) { | ||
return; | ||
} | ||
handleFocus({ | ||
@@ -253,11 +253,3 @@ target: e.currentTarget, | ||
]); | ||
const shouldPreventDefaultKeyboard = (target, key) => { | ||
if (target instanceof HTMLInputElement) { | ||
return !isValidInputKey(target, key); | ||
} | ||
if (target instanceof HTMLButtonElement) { | ||
return target.type !== "submit"; | ||
} | ||
return true; | ||
}; | ||
const shouldPreventDefaultKeyboard = (target) => !(target instanceof HTMLInputElement || target instanceof HTMLButtonElement); | ||
const isHTMLAnchorLink = (target) => target.tagName === "A" && target.hasAttribute("href"); | ||
@@ -264,0 +256,0 @@ const isValidInputKey = (target, key) => ( |
{ | ||
"name": "@mirohq/design-system-use-press", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "", | ||
@@ -30,4 +30,4 @@ "author": "Miro", | ||
"@mirohq/design-system-use-listeners": "^0.1.1", | ||
"@mirohq/design-system-utils": "^0.14.3", | ||
"@mirohq/design-system-use-logger": "^0.1.5" | ||
"@mirohq/design-system-use-logger": "^0.1.5", | ||
"@mirohq/design-system-utils": "^0.14.3" | ||
}, | ||
@@ -34,0 +34,0 @@ "scripts": { |
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
167944
1677