mirror of
https://github.com/vector-im/element-web.git
synced 2025-11-28 22:11:41 +01:00
Replace focus_room_filter dispatch by Action.OpenSpotlight (#29259)
* refactor(room search): replace `focus_room_filter` dispatch by `Action.OpenSpotlight` * test(LoggedInView): add test to Ctrl+k shortcut
This commit is contained in:
parent
4b9382f888
commit
85f80b1d0a
@ -501,9 +501,7 @@ class LoggedInView extends React.Component<IProps, IState> {
|
||||
handled = true;
|
||||
break;
|
||||
case KeyBindingAction.FilterRooms:
|
||||
dis.dispatch({
|
||||
action: "focus_room_filter",
|
||||
});
|
||||
dis.fire(Action.OpenSpotlight);
|
||||
handled = true;
|
||||
break;
|
||||
case KeyBindingAction.ToggleUserMenu:
|
||||
|
||||
@ -11,7 +11,6 @@ import * as React from "react";
|
||||
|
||||
import { ALTERNATE_KEY_NAME } from "../../accessibility/KeyboardShortcuts";
|
||||
import defaultDispatcher from "../../dispatcher/dispatcher";
|
||||
import { type ActionPayload } from "../../dispatcher/payloads";
|
||||
import { IS_MAC, Key } from "../../Keyboard";
|
||||
import { _t } from "../../languageHandler";
|
||||
import AccessibleButton from "../views/elements/AccessibleButton";
|
||||
@ -22,26 +21,10 @@ interface IProps {
|
||||
}
|
||||
|
||||
export default class RoomSearch extends React.PureComponent<IProps> {
|
||||
private dispatcherRef?: string;
|
||||
|
||||
public componentDidMount(): void {
|
||||
this.dispatcherRef = defaultDispatcher.register(this.onAction);
|
||||
}
|
||||
|
||||
public componentWillUnmount(): void {
|
||||
defaultDispatcher.unregister(this.dispatcherRef);
|
||||
}
|
||||
|
||||
private openSpotlight(): void {
|
||||
defaultDispatcher.fire(Action.OpenSpotlight);
|
||||
}
|
||||
|
||||
private onAction = (payload: ActionPayload): void => {
|
||||
if (payload.action === "focus_room_filter") {
|
||||
this.openSpotlight();
|
||||
}
|
||||
};
|
||||
|
||||
public render(): React.ReactNode {
|
||||
const classes = classNames(
|
||||
{
|
||||
|
||||
@ -421,6 +421,14 @@ describe("<LoggedInView />", () => {
|
||||
expect(defaultDispatcher.dispatch).not.toHaveBeenCalledWith({ action: Action.ViewHomePage });
|
||||
});
|
||||
|
||||
it("should open spotlight when Ctrl+k is fired", async () => {
|
||||
jest.spyOn(defaultDispatcher, "fire");
|
||||
|
||||
getComponent();
|
||||
await userEvent.keyboard("{Control>}k{/Control}");
|
||||
expect(defaultDispatcher.fire).toHaveBeenCalledWith(Action.OpenSpotlight);
|
||||
});
|
||||
|
||||
describe("timezone updates", () => {
|
||||
const userTimezone = "Europe/London";
|
||||
const originalController = SETTINGS["userTimezonePublish"].controller;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user