Merge pull request #82 from cdmbase/master

Fix for empty `input.value` issue and form prefilled issues
This commit is contained in:
Tim Brandin 2016-12-14 15:17:49 +01:00 committed by GitHub
commit f7a32530a4

View file

@ -13,7 +13,7 @@ export class Field extends React.Component {
triggerUpdate() {
// Trigger an onChange on inital load, to support browser prefilled values.
const { onChange } = this.props;
if (this.input) {
if (this.input && this.input.value) {
onChange({ target: { value: this.input.value } });
}
}
@ -25,7 +25,7 @@ export class Field extends React.Component {
componentDidUpdate(prevProps) {
// Re-mount component so that we don't expose browser prefilled passwords if the component was
// a password before and now something else.
if (prevProps.formState !== this.props.formState) {
if (prevProps.id !== this.props.id) {
this.setState({mount: false});
}
else if (!this.state.mount) {