-
Notifications
You must be signed in to change notification settings - Fork 813
[fixed] Multiple modals on page causing contradictory class updates #328
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
Conversation
* Add sauce labs testing info to karma This also removes Node versions 4, 5, 6 from Travis. The node version only matters for development not for use. I don't think it's a problem officially supporting only the latest node for development. * Make specs work under IE 11
this PR allow a stack of modals to give back focus to parent modal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately regarding 'ReactModal__Body--open', it won't fix the case where many modals are stacked and the class should be removed only when the stack is empty.
renderModal({ isOpen: true }); | ||
expect(classList.contains(expectedBodyClass)).toBe(true); | ||
unmountModal(); | ||
expect(classList.contains(expectedBodyClass)).toBe(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the problem. 2 modals were opened, one of those is unmounted, so document.body
should actually have the class ReactModal__Body--open
.
The class should be removed only if all modals were closed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh you're right I reversed that test inadvertently 😿
So the design decision is to allow for modal stacking then? I naively assumed from both an accessibility and UX perspective it should only allow one modal at a time to show. Would there be any consideration to disallowing stacking or is that firmly part of the component?
Thanks for the review and help understanding!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any accessibility and UX problem on stacking modals (regarding that we get to manage the focus and open/exit modals correctly).
Modal should block the UI for a single context or scope (my view). Different from a window
or popup
.
Hope it make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the correct fix for this issue is to have some sorta manager to deal with this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have pretty strict guidelines around modals not being stackable, but I understand that it is not a universal guideline, so keeping the component flexible makes sense.
I'll likely continue to use the shouldComponentUpdate
approach within my composition of the component, but feel free to close if it's not the direction you're looking for 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If using redux or a normal component state, you can set an state to avoid opening more modals at the same time.
Just to illustrate the idea:
{ currentModal: null } // can open
{ currentModal: 'my-modal-1' } // already in use
Related issue #335. |
Relates to #358. |
@ajfuller Thank you so much for the attention to this. |
Changes proposed:
renderPortal()
method.Fixes #218 #231 #308
Used the tests from #326
Acceptance Checklist:
CONTRIBUTING.md
.