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
parent
commit
846577b694
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      components/cascader/__tests__/__snapshots__/demo.test.js.snap
  2. 1
      components/cascader/__tests__/__snapshots__/index.test.js.snap
  3. 10
      components/cascader/index.tsx
  4. 1
      components/form/__tests__/__snapshots__/demo.test.js.snap
  5. 1
      components/input/__tests__/__snapshots__/demo.test.js.snap

1
components/cascader/__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>

1
components/cascader/__tests__/__snapshots__/index.test.js.snap

@ -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>

10
components/cascader/index.tsx

@ -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}

1
components/form/__tests__/__snapshots__/demo.test.js.snap

@ -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>

1
components/input/__tests__/__snapshots__/demo.test.js.snap

@ -632,6 +632,7 @@ Array [
>
<span
class="ant-cascader-picker-label"
title="Zhejiang / Hangzhou / West Lake"
>
Zhejiang / Hangzhou / West Lake
</span>

Loading…
Cancel
Save