mirror of
https://github.com/vector-im/element-web.git
synced 2025-11-29 06:21:20 +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;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
case KeyBindingAction.FilterRooms:
|
case KeyBindingAction.FilterRooms:
|
||||||
dis.dispatch({
|
dis.fire(Action.OpenSpotlight);
|
||||||
action: "focus_room_filter",
|
|
||||||
});
|
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
case KeyBindingAction.ToggleUserMenu:
|
case KeyBindingAction.ToggleUserMenu:
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import * as React from "react";
|
|||||||
|
|
||||||
import { ALTERNATE_KEY_NAME } from "../../accessibility/KeyboardShortcuts";
|
import { ALTERNATE_KEY_NAME } from "../../accessibility/KeyboardShortcuts";
|
||||||
import defaultDispatcher from "../../dispatcher/dispatcher";
|
import defaultDispatcher from "../../dispatcher/dispatcher";
|
||||||
import { type ActionPayload } from "../../dispatcher/payloads";
|
|
||||||
import { IS_MAC, Key } from "../../Keyboard";
|
import { IS_MAC, Key } from "../../Keyboard";
|
||||||
import { _t } from "../../languageHandler";
|
import { _t } from "../../languageHandler";
|
||||||
import AccessibleButton from "../views/elements/AccessibleButton";
|
import AccessibleButton from "../views/elements/AccessibleButton";
|
||||||
@ -22,26 +21,10 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default class RoomSearch extends React.PureComponent<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 {
|
private openSpotlight(): void {
|
||||||
defaultDispatcher.fire(Action.OpenSpotlight);
|
defaultDispatcher.fire(Action.OpenSpotlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onAction = (payload: ActionPayload): void => {
|
|
||||||
if (payload.action === "focus_room_filter") {
|
|
||||||
this.openSpotlight();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public render(): React.ReactNode {
|
public render(): React.ReactNode {
|
||||||
const classes = classNames(
|
const classes = classNames(
|
||||||
{
|
{
|
||||||
|
|||||||
@ -421,6 +421,14 @@ describe("<LoggedInView />", () => {
|
|||||||
expect(defaultDispatcher.dispatch).not.toHaveBeenCalledWith({ action: Action.ViewHomePage });
|
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", () => {
|
describe("timezone updates", () => {
|
||||||
const userTimezone = "Europe/London";
|
const userTimezone = "Europe/London";
|
||||||
const originalController = SETTINGS["userTimezonePublish"].controller;
|
const originalController = SETTINGS["userTimezonePublish"].controller;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user