Skip to content

Commit

Permalink
Fixing modal document padding on mobile (#2151)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrush89 committed Jul 24, 2023
1 parent 0604e5f commit 78e0d17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/small-pants-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@primer/view-components': patch
---

Checking document scrollbar width before making dialog backdrop visible to fix issue with document padding on mobile screens.

<!-- Changed components: Primer::Alpha::Dialog -->
2 changes: 1 addition & 1 deletion app/components/primer/alpha/modal_dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ export class ModalDialogElement extends HTMLElement {
if (this.open) return
this.setAttribute('open', '')
this.setAttribute('aria-disabled', 'false')
this.#overlayBackdrop?.classList.remove('Overlay--hidden')
document.body.style.paddingRight = `${window.innerWidth - document.body.clientWidth}px`
document.body.style.overflow = 'hidden'
this.#overlayBackdrop?.classList.remove('Overlay--hidden')
if (this.#focusAbortController.signal.aborted) {
this.#focusAbortController = new AbortController()
}
Expand Down

0 comments on commit 78e0d17

Please sign in to comment.