diff --git a/packages/dropdown/src/dropdown.vue b/packages/dropdown/src/dropdown.vue index 5b14a628..9fb1940a 100644 --- a/packages/dropdown/src/dropdown.vue +++ b/packages/dropdown/src/dropdown.vue @@ -128,7 +128,11 @@ }, handleClick() { if (this.triggerElm.disabled) return; - this.visible = !this.visible; + if (this.visible) { + this.hide(); + } else { + this.show(); + } }, handleTriggerKeyDown(ev) { const keyCode = ev.keyCode; diff --git a/test/unit/specs/dropdown.spec.js b/test/unit/specs/dropdown.spec.js index a2e31bf5..37f7383d 100644 --- a/test/unit/specs/dropdown.spec.js +++ b/test/unit/specs/dropdown.spec.js @@ -102,12 +102,11 @@ describe('Dropdown', () => { triggerEvent(triggerElm, 'mouseenter'); dropdown.$nextTick(_ => { expect(dropdown.visible).to.not.true; - triggerElm.click(); - dropdown.$nextTick(_ => { + setTimeout(_ => { expect(dropdown.visible).to.be.true; done(); - }); + }, 300); }); }); it('split button', done => {