mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
fix(cascader): menu not showing correct checked keys
This commit is contained in:
parent
41f79ce285
commit
3380c7f521
@ -1,5 +1,11 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 2.17.1 (2021-09-06)
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix `n-cascader` menu not showing correct checked keys.
|
||||
|
||||
## 2.17.0 (2021-09-05)
|
||||
|
||||
### Breaking Changes
|
||||
|
@ -1,5 +1,11 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 2.17.1 (2021-09-06)
|
||||
|
||||
### Fixes
|
||||
|
||||
- 修复 `n-cascader` 菜单未展示正确的选中 key
|
||||
|
||||
## 2.17.0 (2021-09-05)
|
||||
|
||||
### Breaking Changes
|
||||
|
@ -203,8 +203,7 @@ export default defineComponent({
|
||||
const { cascade, multiple } = props
|
||||
if (multiple && Array.isArray(mergedValueRef.value)) {
|
||||
return treeMateRef.value.getCheckedKeys(mergedValueRef.value, {
|
||||
cascade,
|
||||
checkStrategy: props.leafOnly ? 'child' : props.checkStrategy
|
||||
cascade
|
||||
})
|
||||
} else {
|
||||
return {
|
||||
@ -329,29 +328,35 @@ export default defineComponent({
|
||||
}
|
||||
const selectedOptionsRef = computed(() => {
|
||||
if (props.multiple) {
|
||||
const { showPath, separator, labelField } = props
|
||||
const { value } = checkedKeysRef
|
||||
if (Array.isArray(value)) {
|
||||
const { getNode } = treeMateRef.value
|
||||
return value.map((key) => {
|
||||
const node = getNode(key)
|
||||
if (node === null) {
|
||||
return {
|
||||
label: String(key),
|
||||
value: key
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
label: showPath
|
||||
? getPathLabel(node, separator, labelField)
|
||||
: (node.rawNode as any)[labelField],
|
||||
value: node.key
|
||||
}
|
||||
const {
|
||||
showPath,
|
||||
separator,
|
||||
labelField,
|
||||
cascade,
|
||||
leafOnly,
|
||||
checkStrategy
|
||||
} = props
|
||||
const { getCheckedKeys, getNode } = treeMateRef.value
|
||||
const value = getCheckedKeys(checkedKeysRef.value, {
|
||||
cascade,
|
||||
checkStrategy: leafOnly ? 'child' : checkStrategy
|
||||
}).checkedKeys
|
||||
return value.map((key) => {
|
||||
const node = getNode(key)
|
||||
if (node === null) {
|
||||
return {
|
||||
label: String(key),
|
||||
value: key
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
label: showPath
|
||||
? getPathLabel(node, separator, labelField)
|
||||
: (node.rawNode as any)[labelField],
|
||||
value: node.key
|
||||
}
|
||||
}
|
||||
})
|
||||
} else return []
|
||||
})
|
||||
const selectedOptionRef = computed(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user