From b680fa43ecdc177f22c7886dd2354ee20b32816b Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:38:00 +0530 Subject: [PATCH 1/2] fix: Country code missing when typing in phone input. (#10439) --- .../widget/components/Form/PhoneInput.vue | 27 +++---------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/app/javascript/widget/components/Form/PhoneInput.vue b/app/javascript/widget/components/Form/PhoneInput.vue index adb3b452b..5713086d5 100644 --- a/app/javascript/widget/components/Form/PhoneInput.vue +++ b/app/javascript/widget/components/Form/PhoneInput.vue @@ -114,31 +114,10 @@ function setContextValue(code) { context.node.input(localValue.value); } -function dynamicallySetCountryCode(value) { - const safeValue = unref(value); - // This function is used to set the country code dynamically. - // The country and dial code is used to set from the value of the phone number field in the pre-chat form. - if (!safeValue) return; - - // check the number first four digit and check weather it is available in the countries array or not. - const country = countries.value.find(code => - safeValue.startsWith(code.dial_code) - ); - - if (country) { - // if it is available then set the country code and dial code. - activeCountryCode.value = country.id; - activeDialCode.value = country.dial_code; - // set the phone number without dial code. - phoneNumber.value = safeValue.replace(country.dial_code, ''); - } -} - function onChange(e) { phoneNumber.value = e.target.value; - dynamicallySetCountryCode(phoneNumber); // This function is used to set the context value when the user types in the phone number field. - setContextValue(activeDialCode); + setContextValue(activeDialCode.value); } function focusedOrActiveItem(className) { @@ -157,8 +136,8 @@ function scrollToFocusedOrActiveItem(item) { if (focusedOrActiveItemLocal.length > 0) { const dropdown = dropdownRef.value; const dropdownHeight = dropdown.clientHeight; - const itemTop = focusedOrActiveItem[0].offsetTop; - const itemHeight = focusedOrActiveItem[0].offsetHeight; + const itemTop = focusedOrActiveItemLocal[0]?.offsetTop; + const itemHeight = focusedOrActiveItemLocal[0]?.offsetHeight; const scrollPosition = itemTop - dropdownHeight / 2 + itemHeight / 2; dropdown.scrollTo({ top: scrollPosition, From 7d9800d2f89bef6695e8179382d44eb0e51b3ca5 Mon Sep 17 00:00:00 2001 From: Sojan Date: Tue, 19 Nov 2024 18:01:33 +0800 Subject: [PATCH 2/2] Bump version to 3.15.0 --- config/app.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/app.yml b/config/app.yml index ee9eb613f..2c8fa1e11 100644 --- a/config/app.yml +++ b/config/app.yml @@ -1,5 +1,5 @@ shared: &shared - version: '3.14.1' + version: '3.15.0' development: <<: *shared diff --git a/package.json b/package.json index 3742a1b50..fc2de8c7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@chatwoot/chatwoot", - "version": "3.14.1", + "version": "3.15.0", "license": "MIT", "scripts": { "eslint": "eslint app/**/*.{js,vue}",