Skip to content

Commit

Permalink
Merge branch '4.x' into fix/FRA-number-field-4x
Browse files Browse the repository at this point in the history
  • Loading branch information
kaio-donadelli authored Sep 16, 2024
2 parents b066088 + 1d13dc2 commit a7ca385
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Changed the rules for France (FRA) so the number field is shown to users.

## [4.25.0] - 2024-09-13

### Fixed
- Logic to validate if a country should use Number Keyboard (shouldShowNumberKeyboard).

## [4.24.7] - 2024-08-30

### Added
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "address-form",
"vendor": "vtex",
"version": "4.24.7",
"version": "4.25.0",
"title": "address-form React component",
"description": "address-form React component",
"defaultLocale": "en",
Expand Down
9 changes: 6 additions & 3 deletions react/PostalCodeGetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<InputFieldContainer
Expand Down
3 changes: 2 additions & 1 deletion react/country/GBR.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default {
maxLength: 50,
fixedLabel: 'Postcode',
required: true,
mask: '',
// UK has different patterns for postal codes alphanumericals, so we need can't use a mask.
mask: NaN,
regex: /^([A-Za-z][A-Ha-hJ-Yj-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/,
postalCodeAPI: false,
size: 'small',
Expand Down
2 changes: 1 addition & 1 deletion react/country/IRL.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
maxLength: 8,
label: 'postalCode',
required: true,
mask: '999 9999',
mask: 'A99 A9A9',
regex: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}$/,
postalCodeAPI: true,
size: 'small',
Expand Down
2 changes: 1 addition & 1 deletion react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vtex/address-form",
"version": "4.24.7",
"version": "4.25.0",
"description": "address-form React component",
"main": "lib/index.js",
"files": [
Expand Down

0 comments on commit a7ca385

Please sign in to comment.