Browse Source
feat(Cascader): title attributes are added to the selected content text by default (#31237)
* update cascader snapshot
* feat(cascader): Add a friendlier title prompt to the label
pull/31273/head
Pengsha Ying
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
12 additions and
2 deletions
-
components/cascader/__tests__/__snapshots__/demo.test.js.snap
-
components/cascader/__tests__/__snapshots__/index.test.js.snap
-
components/cascader/index.tsx
-
components/form/__tests__/__snapshots__/demo.test.js.snap
-
components/input/__tests__/__snapshots__/demo.test.js.snap
|
|
@ -209,6 +209,7 @@ exports[`renders ./components/cascader/demo/default-value.md correctly 1`] = ` |
|
|
|
> |
|
|
|
<span |
|
|
|
class="ant-cascader-picker-label" |
|
|
|
title="Zhejiang / Hangzhou / West Lake" |
|
|
|
> |
|
|
|
Zhejiang / Hangzhou / West Lake |
|
|
|
</span> |
|
|
|
|
|
@ -1117,6 +1117,7 @@ exports[`Cascader support controlled mode 1`] = ` |
|
|
|
> |
|
|
|
<span |
|
|
|
class="ant-cascader-picker-label" |
|
|
|
title="Zhejiang / Hangzhou / West Lake" |
|
|
|
> |
|
|
|
Zhejiang / Hangzhou / West Lake |
|
|
|
</span> |
|
|
|
|
|
@ -316,7 +316,7 @@ class Cascader extends React.Component<CascaderProps, CascaderState> { |
|
|
|
}; |
|
|
|
|
|
|
|
getLabel() { |
|
|
|
const { options, displayRender = defaultDisplayRender as Function } = this.props; |
|
|
|
const { options, displayRender = defaultDisplayRender } = this.props; |
|
|
|
const names = getFilledFieldNames(this.props); |
|
|
|
const { value } = this.state; |
|
|
|
const unwrappedValue = Array.isArray(value[0]) ? value[0] : value; |
|
|
@ -618,9 +618,15 @@ class Cascader extends React.Component<CascaderProps, CascaderState> { |
|
|
|
inputIcon = <DownOutlined className={arrowCls} />; |
|
|
|
} |
|
|
|
|
|
|
|
const label = this.getLabel(); |
|
|
|
const input: React.ReactElement = children || ( |
|
|
|
<span style={style} className={pickerCls}> |
|
|
|
<span className={`${prefixCls}-picker-label`}>{this.getLabel()}</span> |
|
|
|
<span |
|
|
|
className={`${prefixCls}-picker-label`} |
|
|
|
title={typeof label === 'string' && label ? label : undefined} |
|
|
|
> |
|
|
|
{label} |
|
|
|
</span> |
|
|
|
<Input |
|
|
|
{...inputProps} |
|
|
|
tabIndex={-1} |
|
|
|
|
|
@ -3321,6 +3321,7 @@ exports[`renders ./components/form/demo/register.md correctly 1`] = ` |
|
|
|
> |
|
|
|
<span |
|
|
|
class="ant-cascader-picker-label" |
|
|
|
title="Zhejiang / Hangzhou / West Lake" |
|
|
|
> |
|
|
|
Zhejiang / Hangzhou / West Lake |
|
|
|
</span> |
|
|
|
|
|
@ -632,6 +632,7 @@ Array [ |
|
|
|
> |
|
|
|
<span |
|
|
|
class="ant-cascader-picker-label" |
|
|
|
title="Zhejiang / Hangzhou / West Lake" |
|
|
|
> |
|
|
|
Zhejiang / Hangzhou / West Lake |
|
|
|
</span> |
|
|
|