Skip to content

Commit

Permalink
fix(next/antd): fix single value invalid in PreviewText.Cascader (#2940)
Browse files Browse the repository at this point in the history
  • Loading branch information
ifblooms authored Mar 16, 2022
1 parent 2883c33 commit 33a54e7
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 42 deletions.
24 changes: 14 additions & 10 deletions packages/antd/docs/components/PreviewText.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ export default () => {
x-decorator="FormItem"
title="Cascader Preview"
x-component="PreviewText.Cascader"
default={['hangzhou', 'yuhang']}
default={'yuhang'}
enum={[
{
label: 'Hangzhou',
value: 'hangzhou',
},
{
label: 'Yuhang',
value: 'yuhang',
children: [
{
label: 'Yuhang',
value: 'yuhang',
},
],
},
]}
/>
Expand Down Expand Up @@ -170,15 +172,17 @@ export default () => {
x-decorator="FormItem"
title="Cascader Preview"
x-component="PreviewText.Cascader"
default={['hangzhou', 'yuhang']}
default={'yuhang'}
enum={[
{
label: 'Hangzhou',
value: 'hangzhou',
},
{
label: 'Yuhang',
value: 'yuhang',
children: [
{
label: 'Yuhang',
value: 'yuhang',
},
],
},
]}
/>
Expand Down
24 changes: 14 additions & 10 deletions packages/antd/docs/components/PreviewText.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,17 @@ export default () => {
x-decorator="FormItem"
title="Cascader预览"
x-component="PreviewText.Cascader"
default={['hangzhou', 'yuhang']}
default={'yuhang'}
enum={[
{
label: '杭州',
value: 'hangzhou',
},
{
label: '余杭',
value: 'yuhang',
children: [
{
label: '余杭',
value: 'yuhang',
},
],
},
]}
/>
Expand Down Expand Up @@ -169,15 +171,17 @@ export default () => {
x-decorator="FormItem"
title="Cascader预览"
x-component="PreviewText.Cascader"
default={['hangzhou', 'yuhang']}
default={'yuhang'}
enum={[
{
label: '杭州',
value: 'hangzhou',
},
{
label: '余杭',
value: 'yuhang',
children: [
{
label: '余杭',
value: 'yuhang',
},
],
},
]}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/antd/src/preview-text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ const Cascader: React.FC<CascaderProps> = observer((props) => {
? props.options
: []
const getSelected = () => {
return isArr(props.value) ? props.value : []
return isArr(props.value) ? props.value : [props.value]
}
const getLabels = () => {
const selected = getSelected()
Expand Down
24 changes: 14 additions & 10 deletions packages/next/docs/components/PreviewText.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ export default () => {
x-decorator="FormItem"
title="Cascader Preview"
x-component="PreviewText.Cascader"
default={['hangzhou', 'yuhang']}
default={'yuhang'}
enum={[
{
label: 'Hangzhou',
value: 'hangzhou',
},
{
label: 'Yuhang',
value: 'yuhang',
children: [
{
label: 'Yuhang',
value: 'yuhang',
},
],
},
]}
/>
Expand Down Expand Up @@ -142,15 +144,17 @@ export default () => {
x-decorator="FormItem"
title="Cascader Preview"
x-component="PreviewText.Cascader"
default={['hangzhou', 'yuhang']}
default={'yuhang'}
enum={[
{
label: 'Hangzhou',
value: 'hangzhou',
},
{
label: 'Yuhang',
value: 'yuhang',
children: [
{
label: 'Yuhang',
value: 'yuhang',
},
],
},
]}
/>
Expand Down
24 changes: 14 additions & 10 deletions packages/next/docs/components/PreviewText.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ export default () => {
x-decorator="FormItem"
title="Cascader预览"
x-component="PreviewText.Cascader"
default={['hangzhou', 'yuhang']}
default={'yuhang'}
enum={[
{
label: '杭州',
value: 'hangzhou',
},
{
label: '余杭',
value: 'yuhang',
children: [
{
label: '余杭',
value: 'yuhang',
},
],
},
]}
/>
Expand Down Expand Up @@ -142,15 +144,17 @@ export default () => {
x-decorator="FormItem"
title="Cascader预览"
x-component="PreviewText.Cascader"
default={['hangzhou', 'yuhang']}
default={'yuhang'}
enum={[
{
label: '杭州',
value: 'hangzhou',
},
{
label: '余杭',
value: 'yuhang',
children: [
{
label: '余杭',
value: 'yuhang',
},
],
},
]}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/preview-text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const Cascader: React.FC<CascaderProps> = observer((props) => {
? props.dataSource
: []
const getSelected = () => {
return isArr(props.value) ? props.value : []
return isArr(props.value) ? props.value : [props.value]
}
const getLabels = () => {
const selected = getSelected()
Expand Down

0 comments on commit 33a54e7

Please sign in to comment.