From d2a344c5ee82045b503a94f0baa3aeb2b1312231 Mon Sep 17 00:00:00 2001 From: beatrizmaselli Date: Fri, 13 Sep 2024 22:09:01 +0200 Subject: [PATCH] update rules + shouldShowNumberKeyboard logic --- CHANGELOG.md | 3 +++ react/PostalCodeGetter.js | 9 ++++++--- react/country/GBR.js | 3 ++- react/country/IRL.js | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7909800a..8f7dae7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed +- Logic to validate if a country should use Number Keyboard (shouldShowNumberKeyboard). + ## [4.24.7] - 2024-08-30 ### Added diff --git a/react/PostalCodeGetter.js b/react/PostalCodeGetter.js index bab5aece..f1e5d2be 100644 --- a/react/PostalCodeGetter.js +++ b/react/PostalCodeGetter.js @@ -89,9 +89,12 @@ class PostalCodeGetter extends Component { default: case POSTAL_CODE: { const field = getField('postalCode', rules) - const shouldShowNumberKeyboard = !Number.isNaN( - removeNonWords(field.mask) - ) + const numericString = field.mask ? removeNonWords(field.mask) : '' + const isPurelyNumeric = + numericString === '' || /^\d+$/.test(numericString) + const shouldShowNumberKeyboard = isNaN(field.mask) + ? isPurelyNumeric + : false return (