diff --git a/packages/dropdown-item/index.js b/packages/dropdown-item/index.js index 7e36725f4..6bd1e077f 100644 --- a/packages/dropdown-item/index.js +++ b/packages/dropdown-item/index.js @@ -1,4 +1,4 @@ -import { use, isDef } from '../utils'; +import { use } from '../utils'; import Cell from '../cell'; import Icon from '../icon'; import Popup from '../popup'; @@ -19,7 +19,9 @@ export default sfc({ data() { return { - show: false + transition: true, + showPopup: false, + showWrapper: false }; }, @@ -36,7 +38,19 @@ export default sfc({ methods: { toggle(show) { - this.show = isDef(show) ? show : !this.show; + this.showPopup = !this.showPopup; + + if (this.showPopup) { + this.showWrapper = true; + } + }, + + hide(skipTransition) { + this.showPopup = false; + + if (skipTransition) { + this.transition = false; + } } }, @@ -52,7 +66,7 @@ export default sfc({ title={option.text} titleStyle={{ color: active ? activeColor : '' }} onClick={() => { - this.show = false; + this.showPopup = false; if (option.value !== this.value) { this.$emit('input', option.value); @@ -68,11 +82,11 @@ export default sfc({ const emit = eventName => () => this.$emit(eventName); return ( -
+
{ + this.transition = true; + this.showWrapper = false; + this.$emit('closed'); + }} > {Options} {this.slots('default')} diff --git a/packages/dropdown-menu/index.js b/packages/dropdown-menu/index.js index 57d328088..49ed91a45 100644 --- a/packages/dropdown-menu/index.js +++ b/packages/dropdown-menu/index.js @@ -45,15 +45,15 @@ export default sfc({ this.children.forEach((item, index) => { if (index === active) { item.toggle(); - } else { - item.toggle(false); + } else if (item.showPopup) { + item.hide(true); } }); }, onClickOutside() { this.children.forEach(item => { - item.toggle(false); + item.hide(); }); } }, @@ -70,7 +70,7 @@ export default sfc({ > {item.displayTitle} diff --git a/packages/dropdown-menu/test/__snapshots__/index.spec.js.snap b/packages/dropdown-menu/test/__snapshots__/index.spec.js.snap index 74e0ae9ff..9ba623533 100644 --- a/packages/dropdown-menu/test/__snapshots__/index.spec.js.snap +++ b/packages/dropdown-menu/test/__snapshots__/index.spec.js.snap @@ -4,8 +4,8 @@ exports[`click option 1`] = `
B
B
-