فهرست منبع

修改下拉框事件

ZaiZai 2 سال پیش
والد
کامیت
c49978ae2a

+ 10 - 4
packages/components/select/src/select.vue

@@ -29,6 +29,7 @@
           class="select-trigger"
           @mouseenter="inputHovering = true"
           @mouseleave="inputHovering = false"
+          @click="handleInputClick"
         >
           <div
             v-if="multiple"
@@ -140,6 +141,7 @@
             <input
               v-if="filterable"
               ref="input"
+              :id="id"
               v-model="query"
               type="text"
               :class="[nsSelect.e('input'), nsSelect.is(selectSize)]"
@@ -154,12 +156,11 @@
                 width: `${inputLength / (inputWidth - 32)}%`,
                 maxWidth: `${inputWidth - 42}px`,
               }"
+              @click="handleInputClick"
               @focus="handleFocus"
               @blur="handleBlur"
               @keyup="managePlaceholder"
               @keydown="resetInputState"
-              @keydown.down.prevent="navigateOptions('next')"
-              @keydown.up.prevent="navigateOptions('prev')"
               @keydown.esc="handleKeydownEscape"
               @keydown.enter.stop.prevent="selectOption"
               @keydown.delete="deletePrevTag"
@@ -170,6 +171,8 @@
               @input="debouncedQueryChange"
             />
           </div>
+          <!--@keydown.down.prevent="navigateOptions('next')"
+              @keydown.up.prevent="navigateOptions('prev')"-->
           <el-input
             :id="id"
             ref="reference"
@@ -188,6 +191,7 @@
             :validate-event="false"
             :class="[nsSelect.is('focus', visible)]"
             :tabindex="multiple && filterable ? -1 : undefined"
+            @click="handleInputClick"
             @focus="handleFocus"
             @blur="handleBlur"
             @input="debouncedOnInputChange"
@@ -195,12 +199,12 @@
             @compositionstart="handleComposition"
             @compositionupdate="handleComposition"
             @compositionend="handleComposition"
-            @keydown.down.stop.prevent="navigateOptions('next')"
-            @keydown.up.stop.prevent="navigateOptions('prev')"
             @keydown.enter.stop.prevent="selectOption"
             @keydown.esc="handleKeydownEscape"
             @keydown.tab="visible = false"
           >
+            <!--@keydown.down.stop.prevent="navigateOptions('next')"
+            @keydown.up.stop.prevent="navigateOptions('prev')"-->
             <template v-if="$slots.prefix" #prefix>
               <div
                 style="
@@ -462,6 +466,7 @@ export default defineComponent({
       onOptionDestroy,
       handleMenuEnter,
       handleFocus,
+      handleInputClick,
       blur,
       handleBlur,
       handleClearClick,
@@ -643,6 +648,7 @@ export default defineComponent({
       handleComposition,
       handleMenuEnter,
       handleFocus,
+      handleInputClick,
       blur,
       handleBlur,
       handleClearClick,

+ 9 - 6
packages/components/select/src/useSelect.ts

@@ -776,18 +776,20 @@ export const useSelect = (props, states: States, ctx) => {
 
   const handleFocus = (event: FocusEvent) => {
     if (!states.softFocus) {
-      if (props.automaticDropdown || props.filterable) {
-        if (props.filterable && !states.visible) {
-          states.menuVisibleOnFocus = true
-        }
-        states.visible = true
-      }
       ctx.emit('focus', event)
     } else {
       states.softFocus = false
     }
   }
 
+  const handleInputClick = () => {
+    if (!states.visible) {
+      states.menuVisibleOnFocus = true
+    }
+    states.visible = true
+    //navigateOptions('next')
+  }
+
   const blur = () => {
     states.visible = false
     reference.value?.blur()
@@ -929,6 +931,7 @@ export const useSelect = (props, states: States, ctx) => {
     onOptionDestroy,
     handleMenuEnter,
     handleFocus,
+    handleInputClick,
     blur,
     handleBlur,
     handleClearClick,

+ 0 - 1
packages/components/time-picker/src/common/picker.vue

@@ -109,7 +109,6 @@
           :disabled="pickerDisabled"
           :readonly="!editable || readonly"
           :class="nsRange.b('input')"
-          :data-test="(id as string | undefined)"
           @click="handleClickInput"
           @mousedown="onMouseDownInput"
           @input="handleStartInput"