mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 04:30:06 +08:00
Add maxLength attribute to Input (#7744)
This commit is contained in:
parent
7bfe6878dd
commit
2730344ff7
@ -27,6 +27,7 @@ export interface InputProps extends AbstractInputProps {
|
||||
id?: number | string;
|
||||
name?: string;
|
||||
size?: 'large' | 'default' | 'small';
|
||||
maxLength?: string;
|
||||
disabled?: boolean;
|
||||
readOnly?: boolean;
|
||||
addonBefore?: React.ReactNode;
|
||||
@ -62,6 +63,7 @@ export default class Input extends Component<InputProps, any> {
|
||||
PropTypes.number,
|
||||
]),
|
||||
size: PropTypes.oneOf(['small', 'default', 'large']),
|
||||
maxLength: PropTypes.string,
|
||||
disabled: PropTypes.bool,
|
||||
value: PropTypes.any,
|
||||
defaultValue: PropTypes.any,
|
||||
|
@ -1,5 +1,22 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Input should support maxLength 1`] = `
|
||||
<Input
|
||||
disabled={false}
|
||||
maxLength="3"
|
||||
prefixCls="ant-input"
|
||||
type="text"
|
||||
>
|
||||
<input
|
||||
className="ant-input"
|
||||
disabled={false}
|
||||
maxLength="3"
|
||||
onKeyDown={[Function]}
|
||||
type="text"
|
||||
/>
|
||||
</Input>
|
||||
`;
|
||||
|
||||
exports[`TextArea should support disabled 1`] = `
|
||||
<TextArea
|
||||
disabled={true}
|
||||
@ -14,3 +31,18 @@ exports[`TextArea should support disabled 1`] = `
|
||||
/>
|
||||
</TextArea>
|
||||
`;
|
||||
|
||||
exports[`TextArea should support maxLength 1`] = `
|
||||
<TextArea
|
||||
maxLength="10"
|
||||
prefixCls="ant-input"
|
||||
>
|
||||
<textarea
|
||||
className="ant-input"
|
||||
maxLength="10"
|
||||
onChange={[Function]}
|
||||
onKeyDown={[Function]}
|
||||
style={Object {}}
|
||||
/>
|
||||
</TextArea>
|
||||
`;
|
||||
|
@ -7,6 +7,15 @@ const { TextArea } = Input;
|
||||
|
||||
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
|
||||
|
||||
|
||||
describe('Input', () => {
|
||||
it('should support maxLength', async () => {
|
||||
const wrapper = mount(
|
||||
<Input maxLength="3" />
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
describe('TextArea', () => {
|
||||
it('should auto calculate height according to content length', async () => {
|
||||
const wrapper = mount(
|
||||
@ -27,6 +36,13 @@ describe('TextArea', () => {
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should support maxLength', async () => {
|
||||
const wrapper = mount(
|
||||
<TextArea maxLength="10" />
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('As Form Control', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user