Fix closing all modals (#12728)

* Fix closing all modals

We used `Modal.closeCurrentModal()` in a bunch of places, in all cases
(as far as I can see: it wasn't commented) we meant to close all open
modals. This swaps that function for one that closes all open modals.

Also types the close reason which claimed to be something in a comment,
of course, was wrong because a load of places passed their own random
string which was never used.

* Force close modals

* Try with minimal changes

* Already had a method for this

* Add test

* More tests

* Unused importsd
This commit is contained in:
David Baker 2024-07-05 14:39:13 +01:00 committed by GitHub
parent a7542dc0ac
commit dcf7643d4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 95 additions and 17 deletions

View file

@ -36,7 +36,7 @@ import { mkMessage, stubClient } from "../../../test-utils/test-utils";
import { shouldShowComponent } from "../../../../src/customisations/helpers/UIComponents";
import { UIComponent } from "../../../../src/settings/UIFeature";
import SettingsStore from "../../../../src/settings/SettingsStore";
import Modal from "../../../../src/Modal";
import { clearAllModals } from "../../../test-utils";
jest.mock("../../../../src/customisations/helpers/UIComponents", () => ({
shouldShowComponent: jest.fn(),
@ -90,8 +90,8 @@ describe("RoomGeneralContextMenu", () => {
onFinished = jest.fn();
});
afterEach(() => {
Modal.closeCurrentModal("force");
afterEach(async () => {
await clearAllModals();
});
it("renders an empty context menu for archived rooms", async () => {

View file

@ -25,6 +25,7 @@ import { mocked, Mocked } from "jest-mock";
import InviteDialog from "../../../../src/components/views/dialogs/InviteDialog";
import { InviteKind } from "../../../../src/components/views/dialogs/InviteDialogTypes";
import {
clearAllModals,
filterConsole,
flushPromises,
getMockClientWithEventEmitter,
@ -40,7 +41,6 @@ import { SdkContextClass } from "../../../../src/contexts/SDKContext";
import { IProfileInfo } from "../../../../src/hooks/useProfileInfo";
import { DirectoryMember, startDmOnFirstMessage } from "../../../../src/utils/direct-messages";
import SettingsStore from "../../../../src/settings/SettingsStore";
import Modal from "../../../../src/Modal";
const mockGetAccessToken = jest.fn().mockResolvedValue("getAccessToken");
jest.mock("../../../../src/IdentityAuthClient", () =>
@ -178,8 +178,8 @@ describe("InviteDialog", () => {
SdkContextClass.instance.client = mockClient;
});
afterEach(() => {
Modal.closeCurrentModal();
afterEach(async () => {
await clearAllModals();
SdkContextClass.instance.onLoggedOut();
SdkContextClass.instance.client = undefined;
});