瀏覽代碼

Select: update scroll bar position

Leopoldthecoder 7 年之前
父節點
當前提交
6a99f03e1f

+ 12 - 19
packages/pagination/src/pagination.js

@@ -210,34 +210,27 @@ export default {
           this.oldValue = event.target.value;
         },
         handleBlur({ target }) {
-          this.reassignMaxValue(target);
-        },
-        handleKeyUp(event) {
-          const key = event.key || '';
-          const keyCode = event.keyCode || '';
-          if ((key && key === 'Enter') || (keyCode && keyCode === 13)) {
-            this.reassignMaxValue(event.target);
-            this.handleChange(event.target.value);
-          }
+          this.resetValueIfNeed(target.value);
+          this.reassignMaxValue(target.value);
         },
         handleChange(value) {
           this.$parent.internalCurrentPage = this.$parent.getValidCurrentPage(value);
           this.oldValue = null;
-          this.resetValueIfNeed(target);
+          this.resetValueIfNeed(value);
         },
-        resetValueIfNeed(target) {
-          const num = parseInt(target.value, 10);
+        resetValueIfNeed(value) {
+          const num = parseInt(value, 10);
           if (!isNaN(num)) {
             if (num < 1) {
-              target.value = 1;
+              this.$refs.input.$el.querySelector('input').value = 1;
             } else {
-              this.reassignMaxValue(target);
+              this.reassignMaxValue(value);
             }
           }
         },
-        reassignMaxValue(target) {
-          if (+target.value > this.$parent.internalPageCount) {
-            target.value = this.$parent.internalPageCount;
+        reassignMaxValue(value) {
+          if (+value > this.$parent.internalPageCount) {
+            this.$refs.input.$el.querySelector('input').value = this.$parent.internalPageCount;
           }
         }
       },
@@ -253,10 +246,10 @@ export default {
               value={ this.$parent.internalCurrentPage }
               domPropsValue={ this.$parent.internalCurrentPage }
               type="number"
+              ref="input"
               onChange={ this.handleChange }
               onFocus={ this.handleFocus }
-              onBlur={ this.handleBlur }
-              nativeOnKeyup={ this.handleKeyUp }/>
+              onBlur={ this.handleBlur }/>
             { this.t('el.pagination.pageClassifier') }
           </span>
         );

+ 2 - 0
packages/select/src/select.vue

@@ -90,6 +90,7 @@
           tag="ul"
           wrap-class="el-select-dropdown__wrap"
           view-class="el-select-dropdown__list"
+          ref="scrollbar"
           :class="{ 'is-empty': !allowCreate && query && filteredOptionsCount === 0 }"
           v-show="options.length > 0 && !loading">
           <el-option
@@ -417,6 +418,7 @@
           const menu = this.$refs.popper.$el.querySelector('.el-select-dropdown__wrap');
           scrollIntoView(menu, target);
         }
+        this.$refs.scrollbar && this.$refs.scrollbar.handleScroll();
       },
 
       handleMenuEnter() {

+ 1 - 1
packages/theme-chalk/src/button.scss

@@ -142,7 +142,7 @@
     @include button-size($--button-mini-padding-vertical, $--button-mini-padding-horizontal, $--button-mini-font-size, $--button-mini-border-radius);
   }
   @include m(text) {
-    border: none;
+    border-color: transparent;
     color: $--color-primary;
     background: transparent;
     padding-left: 0;

+ 13 - 41
test/unit/specs/pagination.spec.js

@@ -223,50 +223,22 @@ describe('Pagination', () => {
     };
 
     changeValue(1);
-
     setTimeout(() => {
-      expect(vm.page).to.equal(1);
-      expect(input.value).to.equal('1');
-
-      changeValue(10000);
-
+      expect(input.value).to.equal(1);
+      // 多次输入不在min-max区间内的数字
+      changeValue(0);
       setTimeout(() => {
-        expect(vm.page).to.equal(10);
-
-        changeValue('我好帅');
-
+        expect(input.value).to.equal(1);
+        changeValue(0);
         setTimeout(() => {
-          expect(vm.page).to.equal(1);
-          expect(input.value).to.equal('1');
-
-          // 多次输入不在min-max区间内的数字
-          input.value = 0;
-          triggerEvent(input, 'change');
-          setTimeout(()=>{
-            expect(vm.page).to.equal(1);
-            expect(input.value).to.equal('1');
-
-            input.value = 0;
-            triggerEvent(input, 'change');
-            setTimeout(()=>{
-              expect(vm.page).to.equal(1);
-              expect(input.value).to.equal('1');
-
-              input.value = 1000;
-              triggerEvent(input, 'change');
-              setTimeout(()=>{
-                expect(vm.page).to.equal(10);
-                expect(input.value).to.equal('10');
-
-                input.value = 1000;
-                triggerEvent(input, 'change');
-                setTimeout(()=>{
-                  expect(vm.page).to.equal(10);
-                  expect(input.value).to.equal('10');
-
-                  done();
-                }, 50);
-              }, 50);
+          expect(input.value).to.equal(1);
+          changeValue(1000);
+          setTimeout(() => {
+            expect(input.value).to.equal(10);
+            changeValue(1000);
+            setTimeout(() => {
+              expect(input.value).to.equal(10);
+              done();
             }, 50);
           }, 50);
         }, 50);