Save settings by onBlur callback
This commit is contained in:
parent
fce2434dcd
commit
20f79f1da5
6 changed files with 32 additions and 7 deletions
|
@ -13,9 +13,13 @@ class BlacklistForm extends React.Component {
|
|||
return <div key={index} className='form-blacklist-form-row'>
|
||||
<input data-index={index} type='text' name='url'
|
||||
className='column-url' value={url}
|
||||
onChange={this.bindValue.bind(this)} />
|
||||
onChange={this.bindValue.bind(this)}
|
||||
onBlur={this.props.onBlur}
|
||||
/>
|
||||
<DeleteButton data-index={index} name='delete'
|
||||
onClick={this.bindValue.bind(this)} />
|
||||
onClick={this.bindValue.bind(this)}
|
||||
onBlur={this.props.onBlur}
|
||||
/>
|
||||
</div>;
|
||||
})
|
||||
}
|
||||
|
@ -38,17 +42,22 @@ class BlacklistForm extends React.Component {
|
|||
}
|
||||
|
||||
this.props.onChange(next);
|
||||
if (name === 'delete') {
|
||||
this.props.onBlur();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlacklistForm.propTypes = {
|
||||
value: PropTypes.arrayOf(PropTypes.string),
|
||||
onChange: PropTypes.func,
|
||||
onBlur: PropTypes.func,
|
||||
};
|
||||
|
||||
BlacklistForm.defaultProps = {
|
||||
value: [],
|
||||
onChange: () => {},
|
||||
onBlur: () => {},
|
||||
};
|
||||
|
||||
export default BlacklistForm;
|
||||
|
|
|
@ -20,6 +20,7 @@ class KeymapsForm extends React.Component {
|
|||
type='text' id={name} name={name} key={name}
|
||||
label={label} value={value}
|
||||
onChange={this.bindValue.bind(this)}
|
||||
onBlur={this.props.onBlur}
|
||||
/>;
|
||||
})
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ class PropertiesForm extends React.Component {
|
|||
className='column-input'
|
||||
value={value[name] ? value[name] : ''}
|
||||
onChange={this.bindValue.bind(this)}
|
||||
onBlur={this.props.onBlur}
|
||||
checked={value[name]}
|
||||
/>
|
||||
</label>
|
||||
|
|
|
@ -23,11 +23,15 @@ class SearchForm extends React.Component {
|
|||
return <div key={index} className='form-search-form-row'>
|
||||
<input data-index={index} type='text' name='name'
|
||||
className='column-name' value={engine[0]}
|
||||
onChange={this.bindValue.bind(this)} />
|
||||
onChange={this.bindValue.bind(this)}
|
||||
onBlur={this.props.onBlur}
|
||||
/>
|
||||
<input data-index={index} type='text' name='url'
|
||||
placeholder='http://example.com/?q={}'
|
||||
className='column-url' value={engine[1]}
|
||||
onChange={this.bindValue.bind(this)} />
|
||||
onChange={this.bindValue.bind(this)}
|
||||
onBlur={this.props.onBlur}
|
||||
/>
|
||||
<div className='column-option'>
|
||||
<input data-index={index} type='radio' name='default'
|
||||
checked={value.default === engine[0]}
|
||||
|
@ -66,6 +70,9 @@ class SearchForm extends React.Component {
|
|||
}
|
||||
|
||||
this.props.onChange(next);
|
||||
if (name === 'delete' || name === 'default') {
|
||||
this.props.onBlur();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue