1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 10:16:26 +00:00

improve event handler for ModeSelect

This commit is contained in:
Rokt33r
2016-01-02 13:15:20 +09:00
parent f8ad2eddf3
commit f2f6de717b

View File

@@ -99,9 +99,8 @@ export default class ModeSelect extends React.Component {
e.stopPropagation() e.stopPropagation()
this.handleBlur() this.handleBlur()
break break
case 9:
this.handleBlur()
} }
if (this.props.onKeyDown) this.props.onKeyDown(e)
} }
handleSearchChange (e) { handleSearchChange (e) {
@@ -117,9 +116,10 @@ export default class ModeSelect extends React.Component {
mode: IDLE_MODE, mode: IDLE_MODE,
search: '', search: '',
focusIndex: 0 focusIndex: 0
}, function () {
if (this.props.onBlur) this.props.onBlur()
}) })
} }
if (this.props.onBlur != null) this.props.onBlur()
} }
render () { render () {
@@ -153,7 +153,7 @@ export default class ModeSelect extends React.Component {
return ( return (
<div className={className + ' edit'}> <div className={className + ' edit'}>
<input onKeyDown={e => this.handleSearchKeyDown(e)} ref='search' onChange={e => this.handleSearchChange(e)} value={this.state.search} type='text'/> <input onBlur={e => this.handleBlur(e)} onKeyDown={e => this.handleSearchKeyDown(e)} ref='search' onChange={e => this.handleSearchChange(e)} value={this.state.search} type='text'/>
<div ref='options' className='ModeSelect-options hide'> <div ref='options' className='ModeSelect-options hide'>
{filteredOptions} {filteredOptions}
</div> </div>
@@ -166,5 +166,6 @@ ModeSelect.propTypes = {
className: PropTypes.string, className: PropTypes.string,
value: PropTypes.string, value: PropTypes.string,
onChange: PropTypes.func, onChange: PropTypes.func,
onKeyDown: PropTypes.func,
onBlur: PropTypes.func onBlur: PropTypes.func
} }