diff --git a/packages/components/select/src/select.vue b/packages/components/select/src/select.vue index c3f4cfcad8eb9..85d6694600fa1 100644 --- a/packages/components/select/src/select.vue +++ b/packages/components/select/src/select.vue @@ -3,7 +3,7 @@ ref="selectRef" v-click-outside:[popperRef]="handleClickOutside" :class="[nsSelect.b(), nsSelect.m(selectSize)]" - @mouseenter="states.inputHovering = true" + @[mouseEnterEventName]="states.inputHovering = true" @mouseleave="states.inputHovering = false" @click.prevent.stop="toggleMenu" > diff --git a/packages/components/select/src/useSelect.ts b/packages/components/select/src/useSelect.ts index dc09df258c15d..0b000f9ecbee5 100644 --- a/packages/components/select/src/useSelect.ts +++ b/packages/components/select/src/useSelect.ts @@ -28,6 +28,7 @@ import { debugWarn, isClient, isFunction, + isIOS, isNumber, isUndefined, scrollIntoView, @@ -253,6 +254,12 @@ export const useSelect = (props: ISelectProps, emit) => { : states.selectedLabel }) + // iOS Safari does not handle click events when a mouseenter event is registered and a DOM-change happens in a child + // We use a Vue custom event binding to only register the event on non-iOS devices + // ref.: https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html + // Github Issue: https://github.com/vuejs/vue/issues/9859 + const mouseEnterEventName = computed(() => (isIOS ? null : 'mouseenter')) + watch( () => props.modelValue, (val, oldVal) => { @@ -670,6 +677,10 @@ export const useSelect = (props: ISelectProps, emit) => { const toggleMenu = () => { if (selectDisabled.value) return + // We only set the inputHovering state to true on mouseenter event on iOS devices + // To keep the state updated we set it here to true + if (isIOS) states.inputHovering = true + if (states.menuVisibleOnFocus) { // controlled by automaticDropdown states.menuVisibleOnFocus = false @@ -814,6 +825,7 @@ export const useSelect = (props: ISelectProps, emit) => { hasModelValue, shouldShowPlaceholder, currentPlaceholder, + mouseEnterEventName, showClose, iconComponent, iconReverse,