From a409536ad01c46f7643588c75d8c819920f21778 Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Sun, 27 Jun 2021 17:24:06 +0200 Subject: [PATCH] Prevent scrolling of the page when modals are displayed (#5816) * prevent scroll-chaining in modals * make body overflow hidden to prevent background scrolling --- core/modules/utils/dom/modal.js | 1 + editions/tw5.com/tiddlers/demonstrations/SampleWizard.tid | 2 +- themes/tiddlywiki/vanilla/base.tid | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/modules/utils/dom/modal.js b/core/modules/utils/dom/modal.js index 58ffba6a4..58fe34efe 100644 --- a/core/modules/utils/dom/modal.js +++ b/core/modules/utils/dom/modal.js @@ -243,6 +243,7 @@ Modal.prototype.adjustPageClass = function() { if(windowContainer) { $tw.utils.toggleClass(windowContainer,"tc-modal-displayed",this.modalCount > 0); } + $tw.utils.toggleClass(this.srcDocument.body,"tc-modal-prevent-scroll",this.modalCount > 0); }; exports.Modal = Modal; diff --git a/editions/tw5.com/tiddlers/demonstrations/SampleWizard.tid b/editions/tw5.com/tiddlers/demonstrations/SampleWizard.tid index 5226b71ad..6ce1e3439 100644 --- a/editions/tw5.com/tiddlers/demonstrations/SampleWizard.tid +++ b/editions/tw5.com/tiddlers/demonstrations/SampleWizard.tid @@ -1,6 +1,6 @@ created: 20140912145537860 footer: <$button message="tm-close-tiddler">Close -modified: 20140912145537861 +modified: 20210627054504823 subtitle: I'm a modal wizard title: SampleWizard type: text/vnd.tiddlywiki diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index 256152404..e83cc86b9 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -1942,6 +1942,9 @@ html body.tc-body.tc-single-tiddler-window { border-top: 1px solid <>; } +.tc-modal-prevent-scroll { + overflow: hidden; +} /* ** Centered modals