Skip to content

Commit

Permalink
chore: fix safari autofill
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin committed Sep 6, 2023
1 parent ce18b0c commit 048e1af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {maskitoPhoneOptionsGenerator} from '@maskito/phone';
import metadata from 'libphonenumber-js/min/metadata';

export default maskitoPhoneOptionsGenerator({
countryIsoCode: 'RU',
countryIsoCode: 'HU',
metadata,
strict: false,
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {MaskitoPreprocessor} from '@maskito/core';
import {
AsYouType,
CountryCode,
MetadataJson,
parsePhoneNumber,
Expand All @@ -23,7 +24,14 @@ export function validatePhonePreprocessorGenerator({

// handling autocomplete
if (value && !value.startsWith(cleanCode) && !data) {
return {elementState: {value: prefix + value, selection}};
const formatter = new AsYouType({defaultCountry: countryIsoCode}, metadata);

formatter.input(value);
const numberValue = formatter.getNumberValue() || '';

formatter.reset();

return {elementState: {value: formatter.input(numberValue), selection}};
}

try {
Expand Down

0 comments on commit 048e1af

Please sign in to comment.