Skip to content

Commit d752bdc

Browse files
author
castastrophe
committed
Add mobile meta tags; lock background from scrolling on open modal
1 parent 20cf3ef commit d752bdc

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

elements/pfe-modal/demo/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
56
<title>PatternFly Element | pfe-modal Demo</title>
67

78
<noscript>

elements/pfe-modal/src/pfe-modal.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ class PfeModal extends PFElement {
180180
this._modalWindow.removeAttribute("hidden");
181181
this._overlay.removeAttribute("hidden");
182182
this._outer.removeAttribute("hidden");
183+
// This prevents background scroll
184+
document.body.style.overflow = "hidden";
183185
// Set the focus to the container
184186
this._modalWindow.focus();
185187
} else {
@@ -188,6 +190,8 @@ class PfeModal extends PFElement {
188190
this._modalWindow.setAttribute("hidden", true);
189191
this._overlay.setAttribute("hidden", true);
190192
this._outer.setAttribute("hidden", true);
193+
// Return scrollability
194+
document.body.style.overflow = "auto";
191195
// Move focus back to the trigger element
192196
this.trigger.focus();
193197
}

0 commit comments

Comments
 (0)