react-time-picker
Advanced tools
Comparing version 4.4.3 to 4.4.4
@@ -30,2 +30,3 @@ "use strict"; | ||
var isIEOrEdgeLegacy = typeof window !== 'undefined' && /(MSIE|Trident\/|Edge\/)/.test(window.navigator.userAgent); | ||
var isFirefox = typeof window !== 'undefined' && /Firefox/.test(window.navigator.userAgent); | ||
@@ -90,13 +91,16 @@ function onFocus(event) { | ||
return function onKeyPress(event) { | ||
if (isFirefox) { | ||
// See https://github.com/wojtekmaj/react-time-picker/issues/92 | ||
return; | ||
} | ||
var key = event.key, | ||
input = event.target; | ||
var value = input.value; | ||
var isNumberKey = !isNaN(parseInt(key, 10)); | ||
var isNumberKey = key.length === 1 && /\d/.test(key); | ||
var selection = getSelectionString(input); | ||
if (isNumberKey && (selection || value.length < maxLength)) { | ||
return; | ||
if (!isNumberKey || !(selection || value.length < maxLength)) { | ||
event.preventDefault(); | ||
} | ||
event.preventDefault(); | ||
}; | ||
@@ -103,0 +107,0 @@ } |
{ | ||
"name": "react-time-picker", | ||
"version": "4.4.3", | ||
"version": "4.4.4", | ||
"description": "A time picker for your React app.", | ||
@@ -73,3 +73,4 @@ "main": "dist/entry.js", | ||
}, | ||
"funding": "https://github.com/wojtekmaj/react-time-picker?sponsor=1" | ||
"funding": "https://github.com/wojtekmaj/react-time-picker?sponsor=1", | ||
"packageManager": "yarn@3.1.0" | ||
} |
@@ -16,2 +16,7 @@ import React from 'react'; | ||
const isFirefox = ( | ||
typeof window !== 'undefined' | ||
&& /Firefox/.test(window.navigator.userAgent) | ||
); | ||
function onFocus(event) { | ||
@@ -73,13 +78,16 @@ const { target } = event; | ||
return function onKeyPress(event) { | ||
if (isFirefox) { | ||
// See https://github.com/wojtekmaj/react-time-picker/issues/92 | ||
return; | ||
} | ||
const { key, target: input } = event; | ||
const { value } = input; | ||
const isNumberKey = !isNaN(parseInt(key, 10)); | ||
const isNumberKey = key.length === 1 && /\d/.test(key); | ||
const selection = getSelectionString(input); | ||
if (isNumberKey && (selection || value.length < maxLength)) { | ||
return; | ||
if (!isNumberKey || !(selection || value.length < maxLength)) { | ||
event.preventDefault(); | ||
} | ||
event.preventDefault(); | ||
}; | ||
@@ -86,0 +94,0 @@ } |
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
214351
5481