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

Update the modal component to prevent the page from scrolling behind it when open #805

Merged
merged 2 commits into from
Apr 3, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Updates govuk-frontend from 2.5.1 to 2.9.0 (PR #794)
* Adds small form option to subscription component (PR #803)
* Suppress subscription components heading (PR #804)
* Update the modal component to prevent the page from scrolling behind it when open (PR #805)

## 16.8.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
this.$module = $module[0]
this.$dialogBox = this.$module.querySelector('.gem-c-modal-dialogue__box')
this.$closeButton = this.$module.querySelector('.gem-c-modal-dialogue__close-button')
this.$html = document.querySelector('html')
this.$body = document.querySelector('body')

this.$module.open = this.handleOpen.bind(this)
Expand All @@ -33,8 +34,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
event.preventDefault()
}

this.$body.classList.add('app-o-template__body--modal')
this.$body.classList.add('app-o-template__body--blur')
this.$html.classList.add('gem-o-template--modal')
this.$body.classList.add('gem-o-template__body--modal')
this.$body.classList.add('gem-o-template__body--blur')
this.$focusedElementBeforeOpen = document.activeElement
this.$module.style.display = 'block'
this.$dialogBox.focus()
Expand All @@ -47,8 +49,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
event.preventDefault()
}

this.$body.classList.remove('app-o-template__body--modal')
this.$body.classList.remove('app-o-template__body--blur')
this.$html.classList.remove('gem-o-template--modal')
this.$body.classList.remove('gem-o-template__body--modal')
this.$body.classList.remove('gem-o-template__body--blur')
this.$module.style.display = 'none'
this.$focusedElementBeforeOpen.focus()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,17 @@ $govuk-modal-wide-breakpoint: $govuk-page-width + $govuk-modal-margin * 2 + $gov
touch-action: none;
}

.app-o-template__body--modal {
.gem-o-template--modal {
@include govuk-media-query($media-type: screen) {
alex-ju marked this conversation as resolved.
Show resolved Hide resolved
overflow-y: inherit;
alex-ju marked this conversation as resolved.
Show resolved Hide resolved
}
}

.gem-o-template__body--modal {
alex-ju marked this conversation as resolved.
Show resolved Hide resolved
overflow: hidden;
}

.app-o-template__body--blur {
.gem-o-template__body--blur {
.govuk-skip-link,
.govuk-header,
.govuk-phase-banner,
Expand Down