Bug 1574439 - The search input should focus when Search panel is opened; r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D42471

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan Odvarko 2019-08-20 08:36:07 +00:00
Родитель 938483d542
Коммит 7249733689
2 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -58,6 +58,12 @@ class SearchPanel extends Component {
this.provider = SearchProvider; this.provider = SearchProvider;
} }
componentDidMount() {
if (this.searchboxRef) {
this.searchboxRef.current.focus();
}
}
/** /**
* Custom TreeView label rendering. The search result * Custom TreeView label rendering. The search result
* value isn't rendered in separate column, but in the * value isn't rendered in separate column, but in the

Просмотреть файл

@ -76,7 +76,7 @@ class SearchBox extends PureComponent {
}); });
this.shortcuts.on(this.props.keyShortcut, event => { this.shortcuts.on(this.props.keyShortcut, event => {
event.preventDefault(); event.preventDefault();
this.inputRef.current.focus(); this.focus();
}); });
} }
@ -91,6 +91,12 @@ class SearchBox extends PureComponent {
} }
} }
focus() {
if (this.inputRef) {
this.inputRef.current.focus();
}
}
onChange(inputValue = "") { onChange(inputValue = "") {
if (this.state.value !== inputValue) { if (this.state.value !== inputValue) {
this.setState({ this.setState({