mirror of https://github.com/vector-im/riot-web
Move method & don't wastefullt create elements
Put did update with the other react interface methods & don't bother creating the 'current_value' if we throw it away later.pull/2362/head
parent
455ee4f91b
commit
0db12fcd22
|
@ -64,6 +64,12 @@ export default class NetworkDropdown extends React.Component {
|
|||
document.removeEventListener('click', this.onDocumentClick, false);
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.state.expanded && this.inputTextBox) {
|
||||
this.inputTextBox.focus();
|
||||
}
|
||||
}
|
||||
|
||||
onDocumentClick(ev) {
|
||||
// Close the dropdown if the user clicks anywhere that isn't
|
||||
// within our root element
|
||||
|
@ -181,16 +187,8 @@ export default class NetworkDropdown extends React.Component {
|
|||
</div>;
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
if (this.state.expanded && this.inputTextBox) {
|
||||
this.inputTextBox.focus();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
let current_value = this._makeMenuOption(
|
||||
this.state.selectedServer, this.state.selectedNetwork, false
|
||||
);
|
||||
let current_value;
|
||||
|
||||
let menu;
|
||||
if (this.state.expanded) {
|
||||
|
@ -201,6 +199,10 @@ export default class NetworkDropdown extends React.Component {
|
|||
current_value = <input type="text" className="mx_NetworkDropdown_networkoption"
|
||||
ref={this.collectInputTextBox} onKeyUp={this.onInputKeyUp}
|
||||
/>
|
||||
} else {
|
||||
current_value = this._makeMenuOption(
|
||||
this.state.selectedServer, this.state.selectedNetwork, false
|
||||
);
|
||||
}
|
||||
|
||||
return <div className="mx_NetworkDropdown" ref={this.collectRoot}>
|
||||
|
|
Loading…
Reference in New Issue