Skip to content

Commit 9d3188a

Browse files
committed
fix: select drop-down option displays an exception for #970
1 parent 75dd9f6 commit 9d3188a

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

components/vc-select/DropdownMenu.jsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ export default {
107107
const menuProps = {
108108
props: {
109109
multiple,
110-
defaultActiveFirst: defaultActiveFirstOption,
111110
itemIcon: multiple ? menuItemSelectedIcon : null,
112111
selectedKeys,
113112
prefixCls: `${prefixCls}-menu`,
@@ -131,11 +130,15 @@ export default {
131130
const activeKeyProps = {};
132131

133132
let clonedMenuItems = menuItems;
133+
let defaultActiveFirst = defaultActiveFirstOption;
134134
if (selectedKeys.length || firstActiveValue) {
135135
if (props.visible && !this.lastVisible) {
136-
activeKeyProps.activeKey =
137-
selectedKeys[0] !== undefined ? selectedKeys[0] : firstActiveValue;
136+
activeKeyProps.activeKey = selectedKeys[0] || firstActiveValue;;
138137
} else if (!visible) {
138+
// Do not trigger auto active since we already have selectedKeys
139+
if (selectedKeys[0]) {
140+
defaultActiveFirst = false;
141+
}
139142
activeKeyProps.activeKey = undefined;
140143
}
141144
let foundFirst = false;
@@ -180,7 +183,7 @@ export default {
180183
if (inputValue !== this.lastInputValue && (!lastValue || lastValue !== backfillValue)) {
181184
activeKeyProps.activeKey = '';
182185
}
183-
menuProps.props = { ...activeKeyProps, ...menuProps.props };
186+
menuProps.props = { ...activeKeyProps, ...menuProps.props, ...{defaultActiveFirst} };
184187
return <Menu {...menuProps}>{clonedMenuItems}</Menu>;
185188
}
186189
return null;

site/dev.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Api from './components/api';
1212
import './components';
1313
import demoBox from './components/demoBox';
1414
import demoContainer from './components/demoContainer';
15-
import Test from '../components/date-picker/demo/index.vue';
15+
import Test from '../components/test/index.vue';
1616
import zhCN from './theme/zh-CN';
1717
import enUS from './theme/en-US';
1818
Vue.use(Vuex);

0 commit comments

Comments
 (0)