Close context menu when a modal is opened to prevent user getting stuck (#9560)
This commit is contained in:
parent
7fbdd8bb5d
commit
da779531f1
4 changed files with 81 additions and 3 deletions
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -69,6 +69,9 @@ jest.mock('../../../../src/stores/OwnProfileStore', () => ({
|
|||
|
||||
jest.mock('../../../../src/Modal', () => ({
|
||||
createDialog: jest.fn(),
|
||||
on: jest.fn(),
|
||||
off: jest.fn(),
|
||||
ModalManagerEvent: { Opened: "opened" },
|
||||
}));
|
||||
|
||||
describe('<LocationShareMenu />', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue