Skip to content

Commit

Permalink
fix(antd/next): fix PreviewText.Cascader bug (#2969)
Browse files Browse the repository at this point in the history
  • Loading branch information
ifblooms authored Mar 22, 2022
1 parent 06629b0 commit 9990b66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/antd/src/preview-text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,15 @@ const Cascader: React.FC<CascaderProps> = observer((props) => {
? props.options
: []
const getSelected = () => {
return isArr(props.value) ? props.value : [props.value]
return props.multiple
? props.value.map((item) => item[item.length - 1])
: props.value.slice(props.value.length - 1)
}
const getLabels = () => {
const selected = getSelected()
const labels = getValueByValue(dataSource, selected)
?.filter((item) => isValid(item))
?.map((item) => item?.whole.join('/'))
?.map((item) => item?.whole?.join('/'))
.join(', ')
return labels || placeholder
}
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/preview-text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ const Cascader: React.FC<CascaderProps> = observer((props) => {
? props.dataSource
: []
const getSelected = () => {
return isArr(props.value) ? props.value : [props.value]
return props.multiple ? props.value : [props.value]
}
const getLabels = () => {
const selected = getSelected()
const labels = getValueByValue(dataSource, selected)
?.filter((item) => isValid(item))
?.map((item) => item?.whole.join('/'))
?.map((item) => item?.whole?.join('/'))
.join(', ')
return labels || placeholder
}
Expand Down

0 comments on commit 9990b66

Please sign in to comment.