From cc689f95d8916f45bdfae7a30b5fc02994e8790f Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 14 Dec 2021 16:06:45 +0000 Subject: [PATCH] Fix room search sometimes not opening spotlight (#7363) --- src/components/structures/RoomSearch.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/structures/RoomSearch.tsx b/src/components/structures/RoomSearch.tsx index 0ac762409c..cd4f022341 100644 --- a/src/components/structures/RoomSearch.tsx +++ b/src/components/structures/RoomSearch.tsx @@ -118,19 +118,17 @@ export default class RoomSearch extends React.PureComponent { this.setState({ query: this.inputRef.current.value }); }; - private onMouseDown = (ev: React.MouseEvent) => { + private onFocus = (ev: React.FocusEvent) => { if (SettingsStore.getValue("feature_spotlight")) { ev.preventDefault(); ev.stopPropagation(); this.openSpotlight(); + } else { + this.setState({ focused: true }); + ev.target.select(); } }; - private onFocus = (ev: React.FocusEvent) => { - this.setState({ focused: true }); - ev.target.select(); - }; - private onBlur = (ev: React.FocusEvent) => { this.setState({ focused: false }); }; @@ -156,7 +154,11 @@ export default class RoomSearch extends React.PureComponent { }; public focus = (): void => { - this.inputRef.current?.focus(); + if (SettingsStore.getValue("feature_spotlight")) { + this.openSpotlight(); + } else { + this.inputRef.current?.focus(); + } }; public render(): React.ReactNode { @@ -181,7 +183,6 @@ export default class RoomSearch extends React.PureComponent { ref={this.inputRef} className={inputClasses} value={this.state.query} - onMouseDown={this.onMouseDown} onFocus={this.onFocus} onBlur={this.onBlur} onChange={this.onChange}