Skip to content

Commit 2ed0d62

Browse files
committed
fix: select option value support number 0
1 parent c4c75ba commit 2ed0d62

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

components/vc-menu/SubPopupMenu.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function saveRef (key, c) {
4545
export function getActiveKey (props, originalActiveKey) {
4646
let activeKey = originalActiveKey
4747
const { eventKey, defaultActiveFirst, children } = props
48-
if (activeKey) {
48+
if (activeKey !== undefined && activeKey !== null) {
4949
let found
5050
loopMenuItem(children, (c, i) => {
5151
const propsData = c.componentOptions.propsData || {}
@@ -205,7 +205,7 @@ const SubPopupMenu = {
205205

206206
getEventKey () {
207207
// when eventKey not available ,it's menu and return menu id '0-menu-'
208-
return this.eventKey || '0-menu-'
208+
return this.eventKey !== undefined ? this.eventKey : '0-menu-'
209209
},
210210

211211
getOpenTransitionName () {

components/vc-menu/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export function noop () {
33

44
export function getKeyFromChildrenIndex (child, menuEventKey, index) {
55
const prefix = menuEventKey || ''
6-
return child.key || `${prefix}item_${index}`
6+
return child.key === undefined ? `${prefix}item_${index}` : child.key
77
}
88

99
export function getMenuIdFromSubMenuEventKey (eventKey) {

components/vc-select/DropdownMenu.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export default {
126126
let clonedMenuItems = menuItems
127127
if (selectedKeys.length || firstActiveValue) {
128128
if (props.visible && !this.lastVisible) {
129-
activeKeyProps.activeKey = selectedKeys[0] || firstActiveValue
129+
activeKeyProps.activeKey = selectedKeys[0] !== undefined ? selectedKeys[0] : firstActiveValue
130130
}
131131
let foundFirst = false
132132
// set firstActiveItem via cloning menus

components/vc-select/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export function getSelectKeys (menuItems, value) {
122122
} else {
123123
const itemValue = getValuePropValue(item)
124124
const itemKey = item.key
125-
if (findIndexInValueBySingleValue(value, itemValue) !== -1 && itemKey) {
125+
if (findIndexInValueBySingleValue(value, itemValue) !== -1 && itemKey !== undefined) {
126126
selectedKeys.push(itemKey)
127127
}
128128
}

0 commit comments

Comments
 (0)