From ea4e9dba8e624d8b1d51318eb9cf918dd6d778f6 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Wed, 2 Oct 2019 13:37:41 -0400 Subject: [PATCH] FIX: Apply Visual Viewport composer height calc in iOS only --- .../javascripts/discourse/components/composer-body.js.es6 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/components/composer-body.js.es6 b/app/assets/javascripts/discourse/components/composer-body.js.es6 index b1af547ebb2..99cf7b65f48 100644 --- a/app/assets/javascripts/discourse/components/composer-body.js.es6 +++ b/app/assets/javascripts/discourse/components/composer-body.js.es6 @@ -132,12 +132,16 @@ export default Ember.Component.extend(KeyEnterEscape, { $document.on(END_EVENTS, endDrag); }); - if (window.visualViewport !== undefined) { + if (this.shouldUseVisualViewportListener()) { this.viewportResize(); window.visualViewport.addEventListener("resize", this.viewportResize); } }, + shouldUseVisualViewportListener() { + return this.capabilities.isIOS && window.visualViewport !== undefined; + }, + viewportResize() { const composerVH = window.visualViewport.height * 0.01; @@ -174,7 +178,7 @@ export default Ember.Component.extend(KeyEnterEscape, { willDestroyElement() { this._super(...arguments); this.appEvents.off("composer:resize", this, this.resize); - if (window.visualViewport !== undefined) { + if (this.shouldUseVisualViewportListener()) { window.visualViewport.removeEventListener("resize", this.viewportResize); } },