mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-12 20:43:11 +08:00
parent
9583bb4c85
commit
bf82b4c49b
@ -22,15 +22,17 @@ export default class Search extends React.Component<SearchProps, any> {
|
|||||||
this.input.focus();
|
this.input.focus();
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
const { className, inputPrefixCls, prefixCls, ...others } = this.props;
|
const { className, inputPrefixCls, prefixCls, suffix, ...others } = this.props;
|
||||||
delete (others as any).onSearch;
|
delete (others as any).onSearch;
|
||||||
const searchSuffix = (
|
const searchIcon = (
|
||||||
<Icon
|
<Icon
|
||||||
className={`${prefixCls}-icon`}
|
className={`${prefixCls}-icon`}
|
||||||
onClick={this.onSearch}
|
onClick={this.onSearch}
|
||||||
type="search"
|
type="search"
|
||||||
|
key="searchIcon"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
const searchSuffix = suffix ? [suffix, searchIcon] : searchIcon;
|
||||||
return (
|
return (
|
||||||
<Input
|
<Input
|
||||||
onPressEnter={this.onSearch}
|
onPressEnter={this.onSearch}
|
||||||
|
@ -17,6 +17,59 @@ exports[`Input should support maxLength 1`] = `
|
|||||||
</Input>
|
</Input>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`Input.Search should support suffix 1`] = `
|
||||||
|
<Search
|
||||||
|
inputPrefixCls="ant-input"
|
||||||
|
prefixCls="ant-input-search"
|
||||||
|
suffix="suffix"
|
||||||
|
>
|
||||||
|
<Input
|
||||||
|
className="ant-input-search"
|
||||||
|
disabled={false}
|
||||||
|
onPressEnter={[Function]}
|
||||||
|
prefixCls="ant-input"
|
||||||
|
suffix={
|
||||||
|
Array [
|
||||||
|
"suffix",
|
||||||
|
<Icon
|
||||||
|
className="ant-input-search-icon"
|
||||||
|
onClick={[Function]}
|
||||||
|
type="search"
|
||||||
|
/>,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
type="text"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="ant-input-search ant-input-affix-wrapper"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
className="ant-input"
|
||||||
|
disabled={false}
|
||||||
|
onKeyDown={[Function]}
|
||||||
|
style={null}
|
||||||
|
type="text"
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
className="ant-input-suffix"
|
||||||
|
>
|
||||||
|
suffix
|
||||||
|
<Icon
|
||||||
|
className="ant-input-search-icon"
|
||||||
|
onClick={[Function]}
|
||||||
|
type="search"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
className="anticon anticon-search ant-input-search-icon"
|
||||||
|
onClick={[Function]}
|
||||||
|
/>
|
||||||
|
</Icon>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</Input>
|
||||||
|
</Search>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`TextArea should support disabled 1`] = `
|
exports[`TextArea should support disabled 1`] = `
|
||||||
<TextArea
|
<TextArea
|
||||||
disabled={true}
|
disabled={true}
|
||||||
|
@ -7,7 +7,6 @@ const { TextArea } = Input;
|
|||||||
|
|
||||||
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
|
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
|
||||||
|
|
||||||
|
|
||||||
describe('Input', () => {
|
describe('Input', () => {
|
||||||
it('should support maxLength', async () => {
|
it('should support maxLength', async () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
@ -16,6 +15,7 @@ describe('Input', () => {
|
|||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('TextArea', () => {
|
describe('TextArea', () => {
|
||||||
it('should auto calculate height according to content length', async () => {
|
it('should auto calculate height according to content length', async () => {
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
@ -77,3 +77,12 @@ describe('As Form Control', () => {
|
|||||||
expect(wrapper.find('textarea').prop('value')).toBe('');
|
expect(wrapper.find('textarea').prop('value')).toBe('');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Input.Search', () => {
|
||||||
|
it('should support suffix', async () => {
|
||||||
|
const wrapper = mount(
|
||||||
|
<Input.Search suffix="suffix" />
|
||||||
|
);
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user