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): fix state update after close #2254

Merged
merged 1 commit into from
Oct 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/modules/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,8 @@ class Modal extends Component {
handleClose = (e) => {
debug('close()')

const { onClose } = this.props
if (onClose) onClose(e, this.props)

this.trySetState({ open: false }, { scrolling: false })
_.invoke(this.props, 'onClose', e, this.props)
this.trySetState({ open: false })
Copy link
Member Author

Choose a reason for hiding this comment

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

My initial suggestion there was falsy. It causes state after onClose was done.

The same effect can be archived when scrolling will be reseted in handleMount.

}

handleIconOverrides = predefinedProps => ({
Expand All @@ -191,19 +189,17 @@ class Modal extends Component {
handleOpen = (e) => {
debug('open()')

const { onOpen } = this.props
if (onOpen) onOpen(e, this.props)

_.invoke(this.props, 'onOpen', e, this.props)
this.trySetState({ open: true })
}

handlePortalMount = (e) => {
debug('handlePortalMount()')

this.setState({ scrolling: false })
this.setPositionAndClassNames()

const { onMount } = this.props
if (onMount) onMount(e, this.props)
_.invoke(this.props, 'onMount', e, this.props)
}

handlePortalUnmount = (e) => {
Expand All @@ -221,9 +217,7 @@ class Modal extends Component {
mountNode.classList.remove('scrolling')

cancelAnimationFrame(this.animationRequestId)

const { onUnmount } = this.props
if (onUnmount) onUnmount(e, this.props)
_.invoke(this.props, 'onUnmount', e, this.props)
}

handleRef = c => (this.ref = c)
Expand Down