Skip to content

Commit

Permalink
fix: parse happened too early
Browse files Browse the repository at this point in the history
  • Loading branch information
gyurielf committed Aug 29, 2023
1 parent 5ec088b commit f5071ce
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import { createEventDispatcher, onMount } from 'svelte';
import { parsePhoneNumberWithError, ParseError } from 'libphonenumber-js/max';
import {
normalizeTelInput,
Expand Down Expand Up @@ -72,7 +72,8 @@
// Update the country and dispatch event
const updateCountry = (countryCode: CountryCode | null) => {
if (countryCode !== country) {
country = prevCountry = countryCode;
country = countryCode;
prevCountry = country;
dispatch('updateCountry', country);
}
return country;
Expand Down Expand Up @@ -172,9 +173,11 @@
dispatch('updateDetailedValue', detailedValue);
}
if (value) {
handleParsePhoneNumber(value, getCountryForPartialE164Number(value) || country);
}
onMount(() => {
if (value) {
handleParsePhoneNumber(value, getCountryForPartialE164Number(value) || country);
}
});
</script>

<input
Expand Down

0 comments on commit f5071ce

Please sign in to comment.