Merge pull request #1835 from lowdefy/phone-input

PhoneNumberInput - undefined (reading 'dial_code')
This commit is contained in:
Sam 2024-07-17 06:24:49 +00:00 committed by GitHub
commit 6f8bd27d9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View File

@ -0,0 +1,5 @@
---
'@lowdefy/blocks-antd': patch
---
Fix undefined property access in PhoneNumberInput component

View File

@ -73,9 +73,9 @@ function AddOnSelect({
mode="single"
notFoundContent={'Not found'}
onChange={(newVal) => {
const input = value?.input;
const region = uniqueValueOptions[newVal].value;
const phone_number = `${region.dial_code}${input}`;
const input = value?.input ?? '';
const region = uniqueValueOptions[newVal]?.value ?? {};
const phone_number = `${region?.dial_code ?? ''}${input}`;
methods.setValue({
input,
@ -207,8 +207,8 @@ const PhoneNumberInput = ({
input = input.replace(regex, properties.replaceInput.replacement ?? '');
}
const region = value.region;
const phone_number = `${region.dial_code}${input}`;
const region = value?.region ?? {};
const phone_number = `${region?.dial_code ?? ''}${input}`;
methods.setValue({
input,