diff --git a/components/vc-select/DropdownMenu.vue b/components/vc-select/DropdownMenu.vue index 35bf7f5ef..2d16545cc 100644 --- a/components/vc-select/DropdownMenu.vue +++ b/components/vc-select/DropdownMenu.vue @@ -3,18 +3,22 @@ import PropTypes from '../_util/vue-types' import toArray from 'rc-util/lib/Children/toArray' import Menu from '../vc-menu' import scrollIntoView from 'dom-scroll-into-view' -import { getSelectKeys, preventDefaultEvent, saveRef } from './util' +import { getSelectKeys, preventDefaultEvent } from './util' +import { cloneElement } from '../_util/vnode' +import BaseMixin from '../_util/BaseMixin' export default { + name: 'DropdownMenu', + mixins: [BaseMixin], props: { defaultActiveFirstOption: PropTypes.bool, value: PropTypes.any, dropdownMenuStyle: PropTypes.object, multiple: PropTypes.bool, - onPopupFocus: PropTypes.func, - onPopupScroll: PropTypes.func, - onMenuDeSelect: PropTypes.func, - onMenuSelect: PropTypes.func, + // onPopupFocus: PropTypes.func, + // onPopupScroll: PropTypes.func, + // onMenuDeSelect: PropTypes.func, + // onMenuSelect: PropTypes.func, prefixCls: PropTypes.string, menuItems: PropTypes.any, inputValue: PropTypes.string, @@ -84,27 +88,37 @@ export default { }, renderMenu () { - const props = this.props + const props = this.$props const { menuItems, defaultActiveFirstOption, value, prefixCls, multiple, - onMenuSelect, inputValue, firstActiveValue, + dropdownMenuStyle, } = props if (menuItems && menuItems.length) { - const menuProps = {} + const selectedKeys = getSelectKeys(menuItems, value) + const menuProps = { + props: { + multiple, + defaultActiveFirst: defaultActiveFirstOption, + focusable: false, + selectedKeys, + prefixCls: `${prefixCls}-menu`, + }, + on: {}, + style: dropdownMenuStyle, + ref: 'menuRef', + } if (multiple) { - menuProps.onDeselect = props.onMenuDeselect - menuProps.onSelect = onMenuSelect + menuProps.on.deselect = this.onMenuDeselect + menuProps.on.select = this.onMenuSelect } else { - menuProps.onClick = onMenuSelect + menuProps.on.click = this.onMenuSelect } - - const selectedKeys = getSelectKeys(menuItems, value) const activeKeyProps = {} let clonedMenuItems = menuItems @@ -124,9 +138,7 @@ export default { ) { foundFirst = true return cloneElement(item, { - ref: ref => { - this.firstActiveItem = ref - }, + ref: 'firstActiveItem', }) } return item @@ -146,34 +158,36 @@ export default { if (inputValue !== this.lastInputValue && (!lastValue || !lastValue.backfill)) { activeKeyProps.activeKey = '' } - + menuProps.props = { ...menuProps.props, ...activeKeyProps } return ( -