Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Fix room search sometimes not opening spotlight (#7363)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Dec 14, 2021
1 parent 7033f86 commit cc689f9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/components/structures/RoomSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,17 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
this.setState({ query: this.inputRef.current.value });
};

private onMouseDown = (ev: React.MouseEvent<HTMLInputElement>) => {
private onFocus = (ev: React.FocusEvent<HTMLInputElement>) => {
if (SettingsStore.getValue("feature_spotlight")) {
ev.preventDefault();
ev.stopPropagation();
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>) => {
this.setState({ focused: false });
};
Expand All @@ -156,7 +154,11 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
};

public focus = (): void => {
this.inputRef.current?.focus();
if (SettingsStore.getValue("feature_spotlight")) {
this.openSpotlight();
} else {
this.inputRef.current?.focus();
}
};

public render(): React.ReactNode {
Expand All @@ -181,7 +183,6 @@ export default class RoomSearch extends React.PureComponent<IProps, IState> {
ref={this.inputRef}
className={inputClasses}
value={this.state.query}
onMouseDown={this.onMouseDown}
onFocus={this.onFocus}
onBlur={this.onBlur}
onChange={this.onChange}
Expand Down

0 comments on commit cc689f9

Please sign in to comment.