Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix cascader placeholder internationalization #19227

Merged
merged 2 commits into from Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -952,7 +952,6 @@ exports[`Cascader should highlight keyword and filter when search in Cascader 1`
},
]
}
placeholder="Please select"
popupClassName=""
popupPlacement="bottomLeft"
popupVisible={true}
Expand Down Expand Up @@ -1250,7 +1249,6 @@ exports[`Cascader should render not found content 1`] = `
},
]
}
placeholder="Please select"
popupClassName=""
popupPlacement="bottomLeft"
popupVisible={true}
Expand Down Expand Up @@ -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}
Expand Down
11 changes: 11 additions & 0 deletions components/cascader/__tests__/index.test.js
Expand Up @@ -491,4 +491,15 @@ describe('Cascader', () => {
);
expect(popupWrapper.render()).toMatchSnapshot();
});

it('placeholder works correctly', () => {
const wrapper = mount(<Cascader options={[]} />);
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);
});
});
3 changes: 1 addition & 2 deletions components/cascader/index.tsx
Expand Up @@ -216,7 +216,6 @@ function warningValueNotExist(list: CascaderOptionType[], fieldNames: FieldNames

class Cascader extends React.Component<CascaderProps, CascaderState> {
static defaultProps = {
placeholder: 'Please select',
transitionName: 'slide-up',
popupPlacement: 'bottomLeft',
options: [],
Expand Down Expand Up @@ -430,7 +429,7 @@ class Cascader extends React.Component<CascaderProps, CascaderState> {
prefixCls: customizePrefixCls,
inputPrefixCls: customizeInputPrefixCls,
children,
placeholder = locale.placeholder,
placeholder = locale.placeholder || 'Please select',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size,
disabled,
className,
Expand Down