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

Feature/modal mount node #1275

Closed

Conversation

dmitrykrylov
Copy link

  • Bug fix
  • New feature
  • Chore
  • Breaking change
  • There is an open issue which this change addresses
  • I have read the CONTRIBUTING document.
  • My commits follow the Git Commit Guidelines
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Relates to #1274
Should I add any unit tests? I'm not sure how to better test this feature

src/Modal.js Outdated
@@ -54,6 +54,7 @@ const propTypes = {
PropTypes.string,
PropTypes.func,
]),
mountNode: PropTypes.any,
Copy link
Member

Choose a reason for hiding this comment

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

We should probably limit this like we do for the targets in tooltip/popover and allow for a DOMElement, function (which will return a DOMElement), or a string (which can be used to find a DOMElement).

There is a util which handles all of those cases, returning the DOMElement if found.

Probably should call it container to match similar functionality/props elsewhere.

Copy link
Author

Choose a reason for hiding this comment

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

I initially had set the value to PropTypes.instanceOf(Element) but then decided to make it same as in Portal

node: PropTypes.any

@@ -235,6 +236,8 @@ class Modal extends React.Component {
}

init() {
const mountNode = this.props.mountNode || document.body;
Copy link
Member

Choose a reason for hiding this comment

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

could probably use defaultProps to default it to document.body

Copy link
Author

Choose a reason for hiding this comment

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

Look at the my first commit. I used defaultProps but when I run npm start it threw an error where document was undefined.

Copy link
Author

Choose a reason for hiding this comment

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

Probably webpack-dev-server works in kind of SSR mode?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I suppose that will happen on the server when document is not defined. What you have here should be fine then.

@virgofx
Copy link
Collaborator

virgofx commented Oct 26, 2018

This won't work with the forthcoming changes as well on server side. Everything in the init() will need to move to client side rendering as this breaks when {open} = true on SSR. Please do not merge this.

@iamandrewluca
Copy link
Contributor

Fixed in #1817

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

4 participants