Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContextualMenu: outside click should be ignored if there is a modal open #1049

Open
lorumic opened this issue Feb 29, 2024 · 2 comments
Open
Labels
Bug 🐛 Something isn't working P3 Triaged Issue has been reviewed as part of legacy backlog grooming (project P3). Triaged: v4 Triaged, to be implemented as part of Vanilla v4

Comments

@lorumic
Copy link
Contributor

lorumic commented Feb 29, 2024

When the closeOnOutsideClick prop of the ContextualMenu is true, it should be explicitly checked that there is no modal open before closing the contextual menu on outside click.

This is because, with the current behaviour, a click inside the modal would be captured as outside click for the ContextualMenu, causing that to be closed, and since the modal can be a direct child of that ContextualMenu, it would end up being removed as well. See the problem more clearly in the following screen capture:

Peek 2024-02-29 23-42

@bartaz bartaz added the P3 Needs decision Needs team agreement in terms of triaging. label Sep 30, 2024
@bartaz
Copy link
Member

bartaz commented Oct 24, 2024

@lorumic Not sure if I fully understand. If Modal is a child of a ContextualMenu, why clicking on modal is recognised as clicking outside of ContextualMenu?

Overall, I don't think we should make any explicit connections between different component (like checking if modals are open from contextual menu). But maybe there could be some flag on ContextualMenu to prevent it from being closed on clicks outside, for cases like this.

@bartaz bartaz added Bug 🐛 Something isn't working P3 Triaged Issue has been reviewed as part of legacy backlog grooming (project P3). Triaged: v4 Triaged, to be implemented as part of Vanilla v4 and removed P3 Needs decision Needs team agreement in terms of triaging. labels Oct 24, 2024
@lorumic
Copy link
Contributor Author

lorumic commented Oct 24, 2024

@lorumic Not sure if I fully understand. If Modal is a child of a ContextualMenu, why clicking on modal is recognised as clicking outside of ContextualMenu?

@bartaz I'm afraid too much time has passed, and in the meantime we have done a complete overhaul of the UX for that modal, so now I cannot experience the issue shown in the screen capture above anymore. Feel free to close this if you think it's not relevant.

EDIT: Actually, I think I can still answer your question though. The Modal is a child of the ContextualMenu but it's opened inside a portal - so that makes it not a child of the root element of the ContextualMenu, but rather, a completely different DOM node. I think this is what causes the issue shown above: the click inside the modal is recognised as a click in a DOM node that is not in the tree of the root element of the ContextualMenu, causing the "close on outside click" effect to take place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 Something isn't working P3 Triaged Issue has been reviewed as part of legacy backlog grooming (project P3). Triaged: v4 Triaged, to be implemented as part of Vanilla v4
Projects
None yet
Development

No branches or pull requests

2 participants