Browse Source

Select: remove unnecessary query when focused

Leopoldthecoder 7 năm trước cách đây
mục cha
commit
3c942d8e93
2 tập tin đã thay đổi với 7 bổ sung2 xóa
  1. 1 1
      packages/dialog/src/component.vue
  2. 6 1
      packages/select/src/select.vue

+ 1 - 1
packages/dialog/src/component.vue

@@ -181,7 +181,7 @@
 
     destroyed() {
       // if appendToBody is true, remove DOM node after destroy
-      if (this.appendToBody && this.$el) {
+      if (this.appendToBody && this.$el && this.$el.parentNode) {
         this.$el.parentNode.removeChild(this.$el);
       }
     }

+ 6 - 1
packages/select/src/select.vue

@@ -278,7 +278,7 @@
         selectedLabel: '',
         hoverIndex: -1,
         query: '',
-        previousQuery: '',
+        previousQuery: null,
         inputHovering: false,
         currentPlaceholder: ''
       };
@@ -323,6 +323,7 @@
             this.$refs.input.blur();
           }
           this.query = '';
+          this.previousQuery = null;
           this.selectedLabel = '';
           this.inputLength = 20;
           this.resetHoverIndex();
@@ -382,6 +383,10 @@
     methods: {
       handleQueryChange(val) {
         if (this.previousQuery === val) return;
+        if (this.previousQuery === null && typeof this.filterMethod === 'function') {
+          this.previousQuery = val;
+          return;
+        }
         this.previousQuery = val;
         this.$nextTick(() => {
           if (this.visible) this.broadcast('ElSelectDropdown', 'updatePopper');