You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-09 08:42:50 +03:00
Close context menu when a modal is opened to prevent user getting stuck (#9560)
This commit is contained in:
committed by
GitHub
parent
7fbdd8bb5d
commit
da779531f1
@@ -20,6 +20,8 @@ import { mount } from "enzyme";
|
||||
|
||||
import ContextMenu, { ChevronFace } from "../../../../src/components/structures/ContextMenu";
|
||||
import UIStore from "../../../../src/stores/UIStore";
|
||||
import Modal from "../../../../src/Modal";
|
||||
import BaseDialog from "../../../../src/components/views/dialogs/BaseDialog";
|
||||
|
||||
describe("<ContextMenu />", () => {
|
||||
// Hardcode window and menu dimensions
|
||||
@@ -141,4 +143,45 @@ describe("<ContextMenu />", () => {
|
||||
expect(actualChevronOffset).toEqual(targetChevronOffset + targetX - actualX);
|
||||
});
|
||||
});
|
||||
|
||||
it("should automatically close when a modal is opened", () => {
|
||||
const targetX = -50;
|
||||
const onFinished = jest.fn();
|
||||
|
||||
mount(
|
||||
<ContextMenu
|
||||
top={0}
|
||||
right={windowSize - targetX - menuSize}
|
||||
chevronFace={ChevronFace.Bottom}
|
||||
onFinished={onFinished}
|
||||
chevronOffset={targetChevronOffset}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(onFinished).not.toHaveBeenCalled();
|
||||
Modal.createDialog(BaseDialog);
|
||||
expect(onFinished).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should not automatically close when a modal is opened under the existing one", () => {
|
||||
const targetX = -50;
|
||||
const onFinished = jest.fn();
|
||||
|
||||
Modal.createDialog(BaseDialog);
|
||||
mount(
|
||||
<ContextMenu
|
||||
top={0}
|
||||
right={windowSize - targetX - menuSize}
|
||||
chevronFace={ChevronFace.Bottom}
|
||||
onFinished={onFinished}
|
||||
chevronOffset={targetChevronOffset}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(onFinished).not.toHaveBeenCalled();
|
||||
Modal.createDialog(BaseDialog, {}, "", false, true);
|
||||
expect(onFinished).not.toHaveBeenCalled();
|
||||
Modal.appendDialog(BaseDialog);
|
||||
expect(onFinished).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user