mirror of https://github.com/vector-im/riot-web
Fix room search sometimes not opening spotlight (#7363)
parent
7033f8696a
commit
cc689f95d8
|
@ -118,19 +118,17 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
|
||||||
this.setState({ query: this.inputRef.current.value });
|
this.setState({ query: this.inputRef.current.value });
|
||||||
};
|
};
|
||||||
|
|
||||||
private onMouseDown = (ev: React.MouseEvent<HTMLInputElement>) => {
|
private onFocus = (ev: React.FocusEvent<HTMLInputElement>) => {
|
||||||
if (SettingsStore.getValue("feature_spotlight")) {
|
if (SettingsStore.getValue("feature_spotlight")) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
this.openSpotlight();
|
this.openSpotlight();
|
||||||
|
} else {
|
||||||
|
this.setState({ focused: true });
|
||||||
|
ev.target.select();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private onFocus = (ev: React.FocusEvent<HTMLInputElement>) => {
|
|
||||||
this.setState({ focused: true });
|
|
||||||
ev.target.select();
|
|
||||||
};
|
|
||||||
|
|
||||||
private onBlur = (ev: React.FocusEvent<HTMLInputElement>) => {
|
private onBlur = (ev: React.FocusEvent<HTMLInputElement>) => {
|
||||||
this.setState({ focused: false });
|
this.setState({ focused: false });
|
||||||
};
|
};
|
||||||
|
@ -156,7 +154,11 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
public focus = (): void => {
|
public focus = (): void => {
|
||||||
this.inputRef.current?.focus();
|
if (SettingsStore.getValue("feature_spotlight")) {
|
||||||
|
this.openSpotlight();
|
||||||
|
} else {
|
||||||
|
this.inputRef.current?.focus();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public render(): React.ReactNode {
|
public render(): React.ReactNode {
|
||||||
|
@ -181,7 +183,6 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
|
||||||
ref={this.inputRef}
|
ref={this.inputRef}
|
||||||
className={inputClasses}
|
className={inputClasses}
|
||||||
value={this.state.query}
|
value={this.state.query}
|
||||||
onMouseDown={this.onMouseDown}
|
|
||||||
onFocus={this.onFocus}
|
onFocus={this.onFocus}
|
||||||
onBlur={this.onBlur}
|
onBlur={this.onBlur}
|
||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
|
|
Loading…
Reference in New Issue