small improvements
This commit is contained in:
parent
413abaef78
commit
238e671f4f
@ -18,9 +18,9 @@ class FindBar extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this._getSuggestions = _.memoize(this._getSuggestions, (value, activeScope) => value + activeScope);
|
this._getSuggestions = _.memoize(this._getSuggestions, (value, activeScope) => value + activeScope);
|
||||||
|
|
||||||
this.compileCommand = this.compileCommand.bind(this);
|
this.compileCommand = this.compileCommand.bind(this);
|
||||||
this.matchCommand = this.matchCommand.bind(this);
|
this.matchCommand = this.matchCommand.bind(this);
|
||||||
|
this.maybeRemoveActiveScope = this.maybeRemoveActiveScope.bind(this);
|
||||||
this.handleChange = this.handleChange.bind(this);
|
this.handleChange = this.handleChange.bind(this);
|
||||||
this.handleKeyDown = this.handleKeyDown.bind(this);
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
||||||
this.handleInputBlur = this.handleInputBlur.bind(this);
|
this.handleInputBlur = this.handleInputBlur.bind(this);
|
||||||
@ -30,7 +30,6 @@ class FindBar extends Component {
|
|||||||
this.highlightCommandFromMouse = this.highlightCommandFromMouse.bind(this);
|
this.highlightCommandFromMouse = this.highlightCommandFromMouse.bind(this);
|
||||||
this.selectCommandFromMouse = this.selectCommandFromMouse.bind(this);
|
this.selectCommandFromMouse = this.selectCommandFromMouse.bind(this);
|
||||||
this.setIgnoreBlur = this.setIgnoreBlur.bind(this);
|
this.setIgnoreBlur = this.setIgnoreBlur.bind(this);
|
||||||
this.renderMenu = this.renderMenu.bind(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
@ -94,6 +93,15 @@ class FindBar extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maybeRemoveActiveScope() {
|
||||||
|
if (this.state.value.length === 0 && this.state.activeScope) {
|
||||||
|
this.setState({
|
||||||
|
activeScope: null,
|
||||||
|
placeholder: ''
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handleChange(event) {
|
handleChange(event) {
|
||||||
this.setState({
|
this.setState({
|
||||||
value: event.target.value,
|
value: event.target.value,
|
||||||
@ -104,12 +112,7 @@ class FindBar extends Component {
|
|||||||
let highlightedIndex, index;
|
let highlightedIndex, index;
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
case 'Backspace':
|
case 'Backspace':
|
||||||
if (this.state.value.length === 0 && this.state.activeScope) {
|
this.maybeRemoveActiveScope();
|
||||||
this.setState({
|
|
||||||
activeScope: null,
|
|
||||||
placeholder: ''
|
|
||||||
});
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'ArrowDown':
|
case 'ArrowDown':
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@ -158,7 +161,7 @@ class FindBar extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
highlightedIndex: 0,
|
highlightedIndex: 0,
|
||||||
isOpen: false
|
isOpen: false
|
||||||
});
|
}, this.maybeRemoveActiveScope);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.setState({
|
this.setState({
|
||||||
@ -253,8 +256,8 @@ class FindBar extends Component {
|
|||||||
ref={(c) => this._input = c}
|
ref={(c) => this._input = c}
|
||||||
onFocus={this.handleInputFocus}
|
onFocus={this.handleInputFocus}
|
||||||
onBlur={this.handleInputBlur}
|
onBlur={this.handleInputBlur}
|
||||||
onChange={(event) => this.handleChange(event)}
|
onChange={this.handleChange}
|
||||||
onKeyDown={(event) => this.handleKeyDown(event)}
|
onKeyDown={this.handleKeyDown}
|
||||||
onClick={this.handleInputClick}
|
onClick={this.handleInputClick}
|
||||||
placeholder={this.state.placeholder}
|
placeholder={this.state.placeholder}
|
||||||
value={this.state.value}
|
value={this.state.value}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user