Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 79ad393

Browse files
author
Dominik Sumer
committed
switched from dynamic fromprops to specific autocomplete
1 parent 1f84a9b commit 79ad393

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### 0.1.1 (November 21, 2017)
2-
- added possibility to add props to form element via [formProps](https://github.com/cat-react/form/blob/master/docs/api.md#formprops) prop
2+
- now it is possible to add an [autoComplete](https://github.com/cat-react/form/blob/master/docs/api.md#autocomplete) prop to the form element
33
- the validation rule `isRequired` now checks for `undefined`, `null` or an empty string. everything else is valid
44

55
### 0.1.0 (October 3, 2017)

docs/api.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Welcome to the `@cat-react/form` API documentation.
1111
- [onValid](#onvalidvalues)
1212
- [onInvalid](#oninvalidvalues-isvalidating)
1313
- [className](#classname)
14-
- [formProps](#formprops)
14+
- [autoComplete](#autocomplete)
1515
- [Input](#input) (HOC for building input fields)
1616
- Retrieves
1717
- [value](#value)
@@ -308,12 +308,12 @@ will result in:
308308

309309
---
310310

311-
### formProps
312-
Props which will be passed directly to the <form> html element.
311+
### autoComplete
312+
AutoComplete prop which will be passed directly to the <form> html element.
313313

314314
For example:
315315
```jsx
316-
<Form formProps={{autocomplete: 'off'}} />
316+
<Form autoComplete="off" />
317317
```
318318

319319
will result in:

examples/Login/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ export default class extends React.Component {
4242
<Form onValid={this.onValid}
4343
onInvalid={this.onInvalid}
4444
onSubmit={this.onSubmit}
45-
onValidSubmit={this.onValidSubmit}>
45+
onValidSubmit={this.onValidSubmit}
46+
autoComplete="off">
4647
<h1>Login</h1>
4748
<BasicInput label="Email address"
4849
name="email"

src/Form.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,15 @@ export default class Form extends React.Component {
205205
}
206206

207207
render() {
208-
const {children, className, formProps} = this.props;
208+
const {children, className, autoComplete} = this.props;
209+
210+
const formProps = {
211+
className,
212+
autoComplete
213+
};
209214

210215
return (
211-
<form className={className} {...formProps} onSubmit={this.onSubmit}>
216+
<form {...formProps} onSubmit={this.onSubmit}>
212217
{children}
213218
</form>
214219
);

tests/Form.spec.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,9 @@ describe('Form', () => {
4343
expect(onInvalid).not.toHaveBeenCalled();
4444
});
4545

46-
it('should pass all props', () => {
47-
let wrapper = shallow(<Form className="myForm" formProps={{autocomplete: 'off', fantasy: true}}><span className="abc">abc</span></Form>);
48-
const props = wrapper.props();
49-
expect(props.autocomplete).toBe('off');
50-
expect(props.className).toBe('myForm');
51-
expect(props.fantasy).toBe(true);
46+
it('should pass all props correctly', () => {
47+
let wrapper = shallow(<Form className="myForm" autoComplete="off"><span className="abc">abc</span></Form>);
48+
expect(wrapper.html()).toBe('<form class="myForm" autocomplete="off"><span class="abc">abc</span></form>');
5249
});
5350

5451
it('should add the vaidationRule', () => {

0 commit comments

Comments
 (0)