From 9533d0f19f94f8e4f77178ab87a2ab9d97b30295 Mon Sep 17 00:00:00 2001 From: LouisMazel Date: Sat, 28 Sep 2024 15:42:14 +0200 Subject: [PATCH] fix(maz-ui): MazPhoneNumberInput - auto-fill --- .../lib/components/MazPhoneNumberInput.vue | 22 ++++++++++++++++++- .../MazPhoneNumberInput/CountrySelector.vue | 2 +- .../MazPhoneNumberInput/PhoneInput.vue | 2 -- packages/lib/components/MazSelect.vue | 9 +++++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/packages/lib/components/MazPhoneNumberInput.vue b/packages/lib/components/MazPhoneNumberInput.vue index e24d8649d1..965e4c2e64 100644 --- a/packages/lib/components/MazPhoneNumberInput.vue +++ b/packages/lib/components/MazPhoneNumberInput.vue @@ -56,6 +56,15 @@ const props = withDefaults(defineProps(), { excludeSelectors: undefined, orientation: 'responsive', searchThreshold: 0.75, + countrySelectAttributes: () => ({ + name: 'country', + autocomplete: 'off', + }), + phoneInputAttributes: () => ({ + name: 'phone', + autocomplete: 'tel', + inputmode: 'tel', + }), }) const emits = defineEmits<{ @@ -179,6 +188,16 @@ export interface Props { * @values "row" | "col" | "responsive" */ orientation?: 'row' | 'col' | 'responsive' + /** + * Meta attributes of the country input + * @default {Record} { autocomplete: 'off', name: 'country' } + */ + countrySelectAttributes?: Record + /** + * Meta attributes of the phone number input + * @default {Record} { autocomplete: 'tel', name: 'phone', inputmode: 'tel' } + */ + phoneInputAttributes?: Record } const { fetchCountryCode, sanitizePhoneNumber, getBrowserLocale } = useMazPhoneNumberInput() @@ -421,6 +440,7 @@ watch( { :error :size :success - type="tel" - inputmode="tel" class="m-phone-input" :class="[ { diff --git a/packages/lib/components/MazSelect.vue b/packages/lib/components/MazSelect.vue index fc2a2f0737..6116b96d03 100644 --- a/packages/lib/components/MazSelect.vue +++ b/packages/lib/components/MazSelect.vue @@ -108,6 +108,11 @@ export interface Props { block?: boolean /** The exclude selectors for the v-closable directive - will exclude the elements from the directive */ excludeSelectors?: string[] + /** + * The autocomplete attribute of the input + * @default 'off' + */ + autocomplete?: string } defineOptions({ @@ -133,6 +138,7 @@ const props = withDefaults(defineProps>(), { excludeSelectors: undefined, searchPlaceholder: 'Search in options', searchThreshold: 0.75, + autocomplete: 'off', }) const emits = defineEmits<{ @@ -644,9 +650,9 @@ function updateValue(inputOption: NormalizedOption, mustCloseList = true) { :border-active="listOpened" :color="color" :model-value="mazInputValue" - autocomplete="off" :size="size" block + :autocomplete :disabled="disabled" @focus.prevent.stop="openList" @blur.prevent.stop="closeList" @@ -691,6 +697,7 @@ function updateValue(inputOption: NormalizedOption, mustCloseList = true) { :color="color" :placeholder="searchPlaceholder" name="search" + inputmode="search" autocomplete="off" tabindex="-1" class="m-select-list__search-input maz-flex-none"