Skip to content

Commit

Permalink
fix: select option value support number 0
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Sep 19, 2018
1 parent c4c75ba commit 2ed0d62
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions components/vc-menu/SubPopupMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function saveRef (key, c) {
export function getActiveKey (props, originalActiveKey) {
let activeKey = originalActiveKey
const { eventKey, defaultActiveFirst, children } = props
if (activeKey) {
if (activeKey !== undefined && activeKey !== null) {
let found
loopMenuItem(children, (c, i) => {
const propsData = c.componentOptions.propsData || {}
Expand Down Expand Up @@ -205,7 +205,7 @@ const SubPopupMenu = {

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

getOpenTransitionName () {
Expand Down
2 changes: 1 addition & 1 deletion components/vc-menu/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export function noop () {

export function getKeyFromChildrenIndex (child, menuEventKey, index) {
const prefix = menuEventKey || ''
return child.key || `${prefix}item_${index}`
return child.key === undefined ? `${prefix}item_${index}` : child.key
}

export function getMenuIdFromSubMenuEventKey (eventKey) {
Expand Down
2 changes: 1 addition & 1 deletion components/vc-select/DropdownMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default {
let clonedMenuItems = menuItems
if (selectedKeys.length || firstActiveValue) {
if (props.visible && !this.lastVisible) {
activeKeyProps.activeKey = selectedKeys[0] || firstActiveValue
activeKeyProps.activeKey = selectedKeys[0] !== undefined ? selectedKeys[0] : firstActiveValue
}
let foundFirst = false
// set firstActiveItem via cloning menus
Expand Down
2 changes: 1 addition & 1 deletion components/vc-select/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function getSelectKeys (menuItems, value) {
} else {
const itemValue = getValuePropValue(item)
const itemKey = item.key
if (findIndexInValueBySingleValue(value, itemValue) !== -1 && itemKey) {
if (findIndexInValueBySingleValue(value, itemValue) !== -1 && itemKey !== undefined) {
selectedKeys.push(itemKey)
}
}
Expand Down

1 comment on commit 2ed0d62

@tangjinzhou
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.