diff --git a/components/cascader/__tests__/__snapshots__/index.test.js.snap b/components/cascader/__tests__/__snapshots__/index.test.js.snap index c8d21910c6fa..f24086a3e1cb 100644 --- a/components/cascader/__tests__/__snapshots__/index.test.js.snap +++ b/components/cascader/__tests__/__snapshots__/index.test.js.snap @@ -952,7 +952,6 @@ exports[`Cascader should highlight keyword and filter when search in Cascader 1` }, ] } - placeholder="Please select" popupClassName="" popupPlacement="bottomLeft" popupVisible={true} @@ -1250,7 +1249,6 @@ exports[`Cascader should render not found content 1`] = ` }, ] } - placeholder="Please select" popupClassName="" popupPlacement="bottomLeft" popupVisible={true} @@ -1578,7 +1576,6 @@ exports[`Cascader should show not found content when options.length is 0 1`] = ` }, ] } - placeholder="Please select" popupClassName="" popupPlacement="bottomLeft" popupVisible={true} diff --git a/components/cascader/__tests__/index.test.js b/components/cascader/__tests__/index.test.js index 4c772ae1b9a0..54cc0b795bfd 100644 --- a/components/cascader/__tests__/index.test.js +++ b/components/cascader/__tests__/index.test.js @@ -491,4 +491,15 @@ describe('Cascader', () => { ); expect(popupWrapper.render()).toMatchSnapshot(); }); + + it('placeholder works correctly', () => { + const wrapper = mount(); + expect(wrapper.find('input').prop('placeholder')).toBe('Please select'); + + const customPlaceholder = 'Custom placeholder'; + wrapper.setProps({ + placeholder: customPlaceholder, + }); + expect(wrapper.find('input').prop('placeholder')).toBe(customPlaceholder); + }); }); diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index 87b48ba24bb6..e35074cbaa4c 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -216,7 +216,6 @@ function warningValueNotExist(list: CascaderOptionType[], fieldNames: FieldNames class Cascader extends React.Component { static defaultProps = { - placeholder: 'Please select', transitionName: 'slide-up', popupPlacement: 'bottomLeft', options: [], @@ -430,7 +429,7 @@ class Cascader extends React.Component { prefixCls: customizePrefixCls, inputPrefixCls: customizeInputPrefixCls, children, - placeholder = locale.placeholder, + placeholder = locale.placeholder || 'Please select', size, disabled, className,