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): set scrolling body class on re-open #2152

Merged
merged 1 commit into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/modules/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class Modal extends Component {
const { onClose } = this.props
if (onClose) onClose(e, this.props)

this.trySetState({ open: false })
this.trySetState({ open: false }, { scrolling: false })
}

handleIconOverrides = predefinedProps => ({
Expand Down
20 changes: 20 additions & 0 deletions test/specs/modules/Modal/Modal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,26 @@ describe('Modal', () => {
})
})

it('adds the scrolling class to the body after re-open', (done) => {
assertBodyClasses('scrolling', false)

window.innerHeight = 10
wrapperMount(<Modal defaultOpen>foo</Modal>)

requestAnimationFrame(() => {
assertBodyClasses('scrolling')
domEvent.click('.ui.dimmer')

assertBodyClasses('scrolling', false)

wrapper.setProps({ open: true })
requestAnimationFrame(() => {
assertBodyClasses('scrolling')
done()
})
})
})

it('removes the scrolling class from the body on unmount', (done) => {
assertBodyClasses('scrolling', false)

Expand Down