Sfoglia il codice sorgente

Tooltip: fix custom tabindex not work (#15619)

Simona 6 anni fa
parent
commit
c27788f993
2 ha cambiato i file con 9 aggiunte e 1 eliminazioni
  1. 1 1
      packages/tooltip/src/main.js
  2. 8 0
      test/unit/specs/tooltip.spec.js

+ 1 - 1
packages/tooltip/src/main.js

@@ -110,7 +110,7 @@ export default {
     this.referenceElm = this.$el;
     if (this.$el.nodeType === 1) {
       this.$el.setAttribute('aria-describedby', this.tooltipId);
-      this.$el.setAttribute('tabindex', 0);
+      this.$el.setAttribute('tabindex', this.tabindex);
       on(this.referenceElm, 'mouseenter', this.show);
       on(this.referenceElm, 'mouseleave', this.hide);
       on(this.referenceElm, 'focus', () => {

+ 8 - 0
test/unit/specs/tooltip.spec.js

@@ -153,4 +153,12 @@ describe('Tooltip', () => {
       }, 100);
     });
   });
+  it('custom tabindex', () => {
+    vm = createVue(`
+      <el-tooltip ref="tooltip" content="提示文字" :tabindex="-1">
+        <button>click</button>
+      </el-tooltip>
+    `, true);
+    expect(vm.$el.getAttribute('tabindex')).to.be.equal('-1');
+  });
 });