FIX: Do not reset original scroll position in iOS to zero

FIX: Do not reset original scroll position in iOS to zero

This avoids scrolling to the top of a post when toggling focus to the composer textarea

diff --git a/app/assets/javascripts/discourse/lib/safari-hacks.js.es6 b/app/assets/javascripts/discourse/lib/safari-hacks.js.es6
index 27865f5..1fb5318 100644
--- a/app/assets/javascripts/discourse/lib/safari-hacks.js.es6
+++ b/app/assets/javascripts/discourse/lib/safari-hacks.js.es6
@@ -140,7 +140,9 @@ function positioningWorkaround($fixedElement) {
       .find(".select-kit > button.is-focused")
       .removeClass("is-focused");
 
-    originalScrollTop = $(window).scrollTop();
+    if ($(window).scrollTop() > 0) {
+      originalScrollTop = $(window).scrollTop();
+    }
 
     setTimeout(function() {
       if (iOSWithVisualViewport()) {

GitHub sha: b20b6c52

1 Like