-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat(Portal): Improve rendering #666
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { Component } from 'react' | ||
import { Button, Header, Icon, Modal } from 'semantic-ui-react' | ||
|
||
class NestedModal extends Component { | ||
state = { open: false } | ||
|
||
open = () => this.setState({ open: true }) | ||
close = () => this.setState({ open: false }) | ||
|
||
render() { | ||
const { open } = this.state | ||
|
||
return ( | ||
<Modal | ||
dimmer={false} | ||
open={open} | ||
onOpen={this.open} | ||
onClose={this.close} | ||
size='small' | ||
trigger={<Button primary icon>Proceed <Icon name='right chevron' /></Button>} | ||
> | ||
<Modal.Header>Modal #2</Modal.Header> | ||
<Modal.Content> | ||
<p>That's everything!</p> | ||
</Modal.Content> | ||
<Modal.Actions> | ||
<Button icon='check' content='All Done' onClick={this.close} /> | ||
</Modal.Actions> | ||
</Modal> | ||
) | ||
} | ||
} | ||
|
||
const ModalExampleMultiple = () => ( | ||
<Modal trigger={<Button>Multiple Modals</Button>}> | ||
<Modal.Header>Modal #1</Modal.Header> | ||
<Modal.Content image> | ||
<div className='image'> | ||
<Icon name='right arrow' /> | ||
</div> | ||
<Modal.Description> | ||
<p>We have more to share with you. Follow us along to modal 2</p> | ||
</Modal.Description> | ||
</Modal.Content> | ||
<Modal.Actions> | ||
<NestedModal /> | ||
</Modal.Actions> | ||
</Modal> | ||
) | ||
|
||
export default ModalExampleMultiple | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,6 +188,8 @@ class Modal extends Component { | |
|
||
return ( | ||
<Portal | ||
closeOnRootNodeClick | ||
closeOnDocumentClick={false} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently we take unhandled Is there any reason why |
||
{...portalProps} | ||
className={dimmerClasses} | ||
mountNode={this.getMountNode()} | ||
|
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.
Any reason this shouldn't be
Children.only(children)
? If so, it could be assigned to a const at the top of the function and used here and in line 329.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 logged both so you can see:
In both cases we need that actual DOM node, not a reference to the component or element.