fix: select drop-down option displays an exception for #970

pull/983/head
wangxueliang 2019-07-16 01:08:14 +08:00
parent 75dd9f6ceb
commit 9d3188a525
2 changed files with 8 additions and 5 deletions

View File

@ -107,7 +107,6 @@ export default {
const menuProps = {
props: {
multiple,
defaultActiveFirst: defaultActiveFirstOption,
itemIcon: multiple ? menuItemSelectedIcon : null,
selectedKeys,
prefixCls: `${prefixCls}-menu`,
@ -131,11 +130,15 @@ export default {
const activeKeyProps = {};
let clonedMenuItems = menuItems;
let defaultActiveFirst = defaultActiveFirstOption;
if (selectedKeys.length || firstActiveValue) {
if (props.visible && !this.lastVisible) {
activeKeyProps.activeKey =
selectedKeys[0] !== undefined ? selectedKeys[0] : firstActiveValue;
activeKeyProps.activeKey = selectedKeys[0] || firstActiveValue;;
} else if (!visible) {
// Do not trigger auto active since we already have selectedKeys
if (selectedKeys[0]) {
defaultActiveFirst = false;
}
activeKeyProps.activeKey = undefined;
}
let foundFirst = false;
@ -180,7 +183,7 @@ export default {
if (inputValue !== this.lastInputValue && (!lastValue || lastValue !== backfillValue)) {
activeKeyProps.activeKey = '';
}
menuProps.props = { ...activeKeyProps, ...menuProps.props };
menuProps.props = { ...activeKeyProps, ...menuProps.props, ...{defaultActiveFirst} };
return <Menu {...menuProps}>{clonedMenuItems}</Menu>;
}
return null;

View File

@ -12,7 +12,7 @@ import Api from './components/api';
import './components';
import demoBox from './components/demoBox';
import demoContainer from './components/demoContainer';
import Test from '../components/date-picker/demo/index.vue';
import Test from '../components/test/index.vue';
import zhCN from './theme/zh-CN';
import enUS from './theme/en-US';
Vue.use(Vuex);