Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
Fixing input type for <Control.text>. Fixes #551
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkpiano committed Dec 1, 2016
1 parent 104c1c6 commit 2310880
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/guides/local.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import { LocalForm, Control } from 'react-redux-form';
export default class MyApp extends React.Component {
handleChange(values) { ... }
handleUpdate(form) { ... }
handleSubmit(values) { ... }
render() {
return (
<LocalForm
onUpdate={(form) => this.handleUpdate(form)}
onChange={(values) => this.handleChange(values)}
onSubmit={(values) => this.handleSubmit(values)}
>
<Control.text model=".username" />
<Control.text model=".password" />
Expand All @@ -35,3 +37,4 @@ The `<LocalForm>` component takes all the [props from the `<Form>` component](..
### Notes
- `redux` and `react-redux` _are_ still required as peer dependencies. This just allows you to not have to set up the boilerplate; e.g., the store and reducers.
- As with any React component, whenever the `<LocalForm>` is unmounted, the component's internal state is _gone_. This can be desirable (or undesirable) depending on your use case, so take this into consideration.
- Just like with `<Form>`, the props `onSubmit` and `onSubmitFailed` will work as expected.
5 changes: 4 additions & 1 deletion src/constants/control-props-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ function createControlPropsMap() {
onFocus: ({ onFocus }) => onFocus,
onKeyPress: ({ onKeyPress }) => onKeyPress,
},
text: textPropsMap,
text: {
...textPropsMap,
type: 'text',
},
textarea: textPropsMap,
file: {
name: (props) => props.name || props.model,
Expand Down
6 changes: 6 additions & 0 deletions test/control-component-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ Object.keys(testContexts).forEach((testKey) => {
get(store.getState().test, 'foo'),
'testing again');
});

if (controlType === 'text') {
it('should have a type="text"', () => {
assert.equal(node.getAttribute('type'), 'text');
});
}
});
});

Expand Down

0 comments on commit 2310880

Please sign in to comment.