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): Only set position when modal is open #721

Merged
merged 1 commit into from
Oct 22, 2016

Conversation

jeffcarbs
Copy link
Member

Fixes #712

The modal has code that continuously calculates its position to:

  • ensure it's centered vertically.
  • add the scrolling class to the body if need be.

This was being called on component mount, which doesn't make sense since the modal itself may not actually be visible. This updates the the setPosition to start when the Portal gets mounted (the modal becomes visible) and stop when the Portal unmounts (the modal is hidden).

This should:

  • reduce the workload being done by modals rendered onto a page.
  • make it so the component doesn't touch the mountNode until the page has been fully rendered. This (I think) should fix Modal relies on document as default renderNode, breaks SSR #712 since the mountNode defaults to document.body which isn't present server-side.

Copy link
Member

@levithomason levithomason left a comment

Choose a reason for hiding this comment

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

Awesome, nice catch!

@levithomason levithomason merged commit 510ca05 into master Oct 22, 2016
@levithomason levithomason deleted the feature/modal-handle-mount branch October 22, 2016 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modal relies on document as default renderNode, breaks SSR
2 participants