fix: select drop-down option displays an exception for #970
parent
75dd9f6ceb
commit
9d3188a525
|
@ -107,7 +107,6 @@ export default {
|
||||||
const menuProps = {
|
const menuProps = {
|
||||||
props: {
|
props: {
|
||||||
multiple,
|
multiple,
|
||||||
defaultActiveFirst: defaultActiveFirstOption,
|
|
||||||
itemIcon: multiple ? menuItemSelectedIcon : null,
|
itemIcon: multiple ? menuItemSelectedIcon : null,
|
||||||
selectedKeys,
|
selectedKeys,
|
||||||
prefixCls: `${prefixCls}-menu`,
|
prefixCls: `${prefixCls}-menu`,
|
||||||
|
@ -131,11 +130,15 @@ export default {
|
||||||
const activeKeyProps = {};
|
const activeKeyProps = {};
|
||||||
|
|
||||||
let clonedMenuItems = menuItems;
|
let clonedMenuItems = menuItems;
|
||||||
|
let defaultActiveFirst = defaultActiveFirstOption;
|
||||||
if (selectedKeys.length || firstActiveValue) {
|
if (selectedKeys.length || firstActiveValue) {
|
||||||
if (props.visible && !this.lastVisible) {
|
if (props.visible && !this.lastVisible) {
|
||||||
activeKeyProps.activeKey =
|
activeKeyProps.activeKey = selectedKeys[0] || firstActiveValue;;
|
||||||
selectedKeys[0] !== undefined ? selectedKeys[0] : firstActiveValue;
|
|
||||||
} else if (!visible) {
|
} else if (!visible) {
|
||||||
|
// Do not trigger auto active since we already have selectedKeys
|
||||||
|
if (selectedKeys[0]) {
|
||||||
|
defaultActiveFirst = false;
|
||||||
|
}
|
||||||
activeKeyProps.activeKey = undefined;
|
activeKeyProps.activeKey = undefined;
|
||||||
}
|
}
|
||||||
let foundFirst = false;
|
let foundFirst = false;
|
||||||
|
@ -180,7 +183,7 @@ export default {
|
||||||
if (inputValue !== this.lastInputValue && (!lastValue || lastValue !== backfillValue)) {
|
if (inputValue !== this.lastInputValue && (!lastValue || lastValue !== backfillValue)) {
|
||||||
activeKeyProps.activeKey = '';
|
activeKeyProps.activeKey = '';
|
||||||
}
|
}
|
||||||
menuProps.props = { ...activeKeyProps, ...menuProps.props };
|
menuProps.props = { ...activeKeyProps, ...menuProps.props, ...{defaultActiveFirst} };
|
||||||
return <Menu {...menuProps}>{clonedMenuItems}</Menu>;
|
return <Menu {...menuProps}>{clonedMenuItems}</Menu>;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -12,7 +12,7 @@ import Api from './components/api';
|
||||||
import './components';
|
import './components';
|
||||||
import demoBox from './components/demoBox';
|
import demoBox from './components/demoBox';
|
||||||
import demoContainer from './components/demoContainer';
|
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 zhCN from './theme/zh-CN';
|
||||||
import enUS from './theme/en-US';
|
import enUS from './theme/en-US';
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
Loading…
Reference in New Issue