From 957ed3666300655e9a09cf6de8287a67b6e1f9e4 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Thu, 12 Dec 2024 19:38:17 -0500 Subject: [PATCH] fine-tune scroll lock on ios reserveScrollBarGap and allow scrolling items inside composer --- .../app/components/d-virtual-height.gjs | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/d-virtual-height.gjs b/app/assets/javascripts/discourse/app/components/d-virtual-height.gjs index 3b77bd3ca6f..984899b286d 100644 --- a/app/assets/javascripts/discourse/app/components/d-virtual-height.gjs +++ b/app/assets/javascripts/discourse/app/components/d-virtual-height.gjs @@ -134,20 +134,21 @@ export default class DVirtualHeight extends Component { this.appEvents.trigger("keyboard-visibility-change", keyboardVisible); - if (keyboardVisible) { - docEl.classList.add("keyboard-visible"); - - // disable body scroll in mobile composer - // we have to do this because we're positioning the composer with - // position: fixed and top: 0 and scrolling would move the composer halfway out of the viewport - // we can't use bottom: 0, it is very unreliable with keyboard visible - if (docEl.classList.contains("composer-open")) { - disableBodyScroll(document.querySelector("#reply-control")); - } + // disable body scroll in mobile composer + // we have to do this because we're positioning the composer with + // position: fixed and top: 0 and scrolling would move the composer halfway out of the viewport + // we can't use bottom: 0, it is very unreliable with keyboard visible + if (docEl.classList.contains("composer-open")) { + disableBodyScroll(document.querySelector("#reply-control"), { + reserveScrollBarGap: true, + allowTouchMove: (el) => el.closest("#reply-control"), + }); } + keyboardVisible + ? docEl.classList.add("keyboard-visible") + : docEl.classList.remove("keyboard-visible"); if (!keyboardVisible) { - docEl.classList.remove("keyboard-visible"); clearAllBodyScrollLocks(); } }