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

Fix room search sometimes not opening spotlight #7363

Merged
merged 2 commits into from
Dec 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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