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

Modal triggered from menu item issues #1106

Closed
cytey opened this issue Jan 2, 2017 · 3 comments
Closed

Modal triggered from menu item issues #1106

cytey opened this issue Jan 2, 2017 · 3 comments

Comments

@cytey
Copy link

cytey commented Jan 2, 2017

Steps

  1. Have a menu
  2. Have a menu item that trigger a modal
  3. Have a modal that has a form with a checkbox
  4. Open the menu
  5. Click on the menu item that trigger the modal
  6. Click on the checkbox in the form of the modal

Expected Result

The checkbox in the form of the modal should be clickable and not dismiss the modal upon click

Actual Result

Upon clicking on any part of the modal, the modal is closed

Version

0.63.4

Testcase

http://codepen.io/anon/pen/zNxXKo?editors=0010

@levithomason
Copy link
Member

Please provide a test case. You can fork the codepen in the issue template.

@cytey
Copy link
Author

cytey commented Jan 6, 2017

@levithomason I have added the testcase. Thanks for your help!

@levithomason
Copy link
Member

Ah, I see. The issue here is that the Modal is owned by the Menu. It actually doesn't matter where you click in the Modal, clicking anywhere (or taking any action) that closes the Menu causes it to unmount which causes the Modal to unmount. Also, in this case, it isn't actually the Menu that is at fault but the Popup that is containing the Menu.

The solution here is going to be separating some of these concerns. I'd recommend moving the Modal higher in the tree, perhaps to the root of your view component, and controlling its open state directly, rather than with a Popup. In this case, your Popup / Menu would toggle some app state showLogoutModal and that is all. Then, your Modal would consume that state to open/close. This way, the Popup is not the owner of the Modal. I believe this is the more "React way" of going about this relationship.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants