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

fix(Modal): unmounting nested modals #321

Merged
merged 1 commit into from Feb 14, 2017

Conversation

hongrich
Copy link
Contributor

@hongrich hongrich commented Feb 1, 2017

Unmounting nested modals should remove the matching number of
modal-open classes from the body node. Previously, the updated class
names were computed before its children are unmounted and only updated
in the DOM afterwards. This can cause modal-open class name to be left
on the body if any of its children is also a modal (which is also trying
to remove those modal-open classes).

Here's an demo of the issue: http://www.webpackbin.com/4J7BkUsPf

  1. Click on Example 2
  2. Click on Show Nested Model <- typo in the example!
  3. Click on All Done which unmounts the example 2 component
  4. Note that there is still a modal-open class left on the body node

Unmounting nested modals should remove the matching number of
`modal-open` classes from the body node. Previously, the updated class
names were computed before its children are unmounted and only updated
in the DOM afterwards. This can cause `modal-open` class name to be left
on the body if any of its children is also a modal (which is also trying
to remove those `modal-open` classes).
jasmine.clock().tick(300);
expect(wrapper.children().length).toBe(0);
expect(document.getElementsByClassName('modal-dialog').length).toBe(2);
expect(document.body.className).toBe('modal-open modal-open');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will need to follow up with a proper fix for duplicate classes by either tracking active modals or using a prop as a flag for managing that body class.

@eddywashere eddywashere merged commit ecf51b2 into reactstrap:master Feb 14, 2017
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

Successfully merging this pull request may close these issues.

None yet

3 participants