diff --git a/components/dropdown/dropdown-button.jsx b/components/dropdown/dropdown-button.jsx index 4a0756293..9264a2ea0 100644 --- a/components/dropdown/dropdown-button.jsx +++ b/components/dropdown/dropdown-button.jsx @@ -1,7 +1,6 @@ import Button from '../button' import { ButtonGroupProps } from '../button/button-group' -import Icon from '../icon' import Dropdown from './dropdown' import PropTypes from '../_util/vue-types' import { hasProp, getComponentFromProp } from '../_util/props-util' diff --git a/components/dropdown/dropdown.jsx b/components/dropdown/dropdown.jsx index ad1dee203..8fb5d6771 100644 --- a/components/dropdown/dropdown.jsx +++ b/components/dropdown/dropdown.jsx @@ -1,7 +1,6 @@ -import RcDropdown from './src/index' +import RcDropdown from '../vc-dropdown/src/index' import DropdownButton from './dropdown-button' -// import warning from '../_util/warning' import PropTypes from '../_util/vue-types' import { cloneElement } from '../_util/vnode' import { getOptionProps, getPropsData } from '../_util/props-util' diff --git a/components/dropdown/src/Dropdown.jsx b/components/vc-dropdown/src/Dropdown.jsx similarity index 86% rename from components/dropdown/src/Dropdown.jsx rename to components/vc-dropdown/src/Dropdown.jsx index f535eaaa2..aec9cb123 100644 --- a/components/dropdown/src/Dropdown.jsx +++ b/components/vc-dropdown/src/Dropdown.jsx @@ -2,7 +2,7 @@ import PropTypes from '../../_util/vue-types' import Trigger from '../../trigger' import placements from './placements' -import { hasProp, getEvents } from '../../_util/props-util' +import { hasProp, getEvents, getOptionProps } from '../../_util/props-util' import BaseMixin from '../../_util/BaseMixin' import { cloneElement } from '../../_util/vnode' @@ -18,6 +18,7 @@ export default { overlayStyle: PropTypes.object.def({}), placement: PropTypes.string.def('bottomLeft'), trigger: PropTypes.array.def(['hover']), + alignPoint: PropTypes.bool, showAction: PropTypes.array.def([]), hideAction: PropTypes.array.def([]), getPopupContainer: PropTypes.func, @@ -67,6 +68,16 @@ export default { this.__emit('visibleChange', visible) }, + getMinOverlayWidthMatchTrigger () { + const props = getOptionProps(this) + const { minOverlayWidthMatchTrigger, alignPoint } = props + if ('minOverlayWidthMatchTrigger' in props) { + return minOverlayWidthMatchTrigger + } + + return !alignPoint + }, + getMenuElement () { const { onClick, prefixCls, $slots } = this this.childOriginEvents = getEvents($slots.overlay[0]) @@ -87,7 +98,7 @@ export default { }, afterVisibleChange (visible) { - if (visible && this.$props.minOverlayWidthMatchTrigger) { + if (visible && this.getMinOverlayWidthMatchTrigger()) { const overlayNode = this.getPopupDomNode() const rootNode = this.$el if (rootNode && overlayNode && rootNode.offsetWidth > overlayNode.offsetWidth) { @@ -111,6 +122,10 @@ export default { overlayClassName, overlayStyle, trigger, ...otherProps } = this.$props + let triggerHideAction = hideAction + if (!triggerHideAction && trigger.indexOf('contextmenu') !== -1) { + triggerHideAction = ['click'] + } const triggerProps = { props: { @@ -121,7 +136,7 @@ export default { builtinPlacements: placements, action: trigger, showAction, - hideAction, + hideAction: triggerHideAction || [], popupPlacement: placement, popupAlign: align, popupTransitionName: transitionName, diff --git a/components/dropdown/src/index.js b/components/vc-dropdown/src/index.js similarity index 77% rename from components/dropdown/src/index.js rename to components/vc-dropdown/src/index.js index 7f53b7141..bcabbb996 100644 --- a/components/dropdown/src/index.js +++ b/components/vc-dropdown/src/index.js @@ -1,2 +1,3 @@ +// base in 2.2.1 import Dropdown from './Dropdown' export default Dropdown diff --git a/components/dropdown/src/placements.js b/components/vc-dropdown/src/placements.js similarity index 100% rename from components/dropdown/src/placements.js rename to components/vc-dropdown/src/placements.js