mirror of https://github.com/vector-im/riot-web
Extract `focus_search` dispatch action into enum (#12721)
* Extract `focus_search` dispatch action into enum Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * copypasta Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/28217/head
parent
b0d2010247
commit
6b90fe20ab
|
@ -458,9 +458,7 @@ class LoggedInView extends React.Component<IProps, IState> {
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
case KeyBindingAction.SearchInRoom:
|
case KeyBindingAction.SearchInRoom:
|
||||||
dis.dispatch({
|
dis.fire(Action.FocusMessageSearch);
|
||||||
action: "focus_search",
|
|
||||||
});
|
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1196,7 +1196,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "focus_search":
|
case Action.FocusMessageSearch:
|
||||||
this.onSearchClick();
|
this.onSearchClick();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -388,4 +388,9 @@ export enum Action {
|
||||||
* Opens right panel with 3pid invite information
|
* Opens right panel with 3pid invite information
|
||||||
*/
|
*/
|
||||||
View3pidInvite = "view_3pid_invite",
|
View3pidInvite = "view_3pid_invite",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens right panel room summary and focuses the search input
|
||||||
|
*/
|
||||||
|
FocusMessageSearch = "focus_search",
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { render, RenderResult } from "@testing-library/react";
|
||||||
import { ConditionKind, EventType, IPushRule, MatrixEvent, ClientEvent, PushRuleKind } from "matrix-js-sdk/src/matrix";
|
import { ConditionKind, EventType, IPushRule, MatrixEvent, ClientEvent, PushRuleKind } from "matrix-js-sdk/src/matrix";
|
||||||
import { MediaHandler } from "matrix-js-sdk/src/webrtc/mediaHandler";
|
import { MediaHandler } from "matrix-js-sdk/src/webrtc/mediaHandler";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
import userEvent from "@testing-library/user-event";
|
||||||
|
|
||||||
import LoggedInView from "../../../src/components/structures/LoggedInView";
|
import LoggedInView from "../../../src/components/structures/LoggedInView";
|
||||||
import { SDKContext } from "../../../src/contexts/SDKContext";
|
import { SDKContext } from "../../../src/contexts/SDKContext";
|
||||||
|
@ -26,6 +27,10 @@ import { StandardActions } from "../../../src/notifications/StandardActions";
|
||||||
import ResizeNotifier from "../../../src/utils/ResizeNotifier";
|
import ResizeNotifier from "../../../src/utils/ResizeNotifier";
|
||||||
import { flushPromises, getMockClientWithEventEmitter, mockClientMethodsUser } from "../../test-utils";
|
import { flushPromises, getMockClientWithEventEmitter, mockClientMethodsUser } from "../../test-utils";
|
||||||
import { TestSdkContext } from "../../TestSdkContext";
|
import { TestSdkContext } from "../../TestSdkContext";
|
||||||
|
import defaultDispatcher from "../../../src/dispatcher/dispatcher";
|
||||||
|
import SettingsStore from "../../../src/settings/SettingsStore";
|
||||||
|
import { SettingLevel } from "../../../src/settings/SettingLevel";
|
||||||
|
import { Action } from "../../../src/dispatcher/actions";
|
||||||
|
|
||||||
describe("<LoggedInView />", () => {
|
describe("<LoggedInView />", () => {
|
||||||
const userId = "@alice:domain.org";
|
const userId = "@alice:domain.org";
|
||||||
|
@ -384,4 +389,13 @@ describe("<LoggedInView />", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should fire FocusMessageSearch on Ctrl+F when enabled", async () => {
|
||||||
|
jest.spyOn(defaultDispatcher, "fire");
|
||||||
|
await SettingsStore.setValue("ctrlFForSearch", null, SettingLevel.DEVICE, true);
|
||||||
|
|
||||||
|
getComponent();
|
||||||
|
await userEvent.keyboard("{Control>}f{/Control}");
|
||||||
|
expect(defaultDispatcher.fire).toHaveBeenCalledWith(Action.FocusMessageSearch);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue