From 2e860eddc12289bc18417e309c8d53fe206fb457 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 1 Dec 2017 17:07:28 +0800 Subject: [PATCH] Don't sync scroll when input is not scrollable. https://meta.discourse.org/t/composer-preview-scroll-not-syncing-with-editor/74975/14?u=tgxworld --- .../javascripts/discourse/components/composer-editor.js.es6 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/components/composer-editor.js.es6 b/app/assets/javascripts/discourse/components/composer-editor.js.es6 index 4b95913aa45..1d715a396de 100644 --- a/app/assets/javascripts/discourse/components/composer-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/composer-editor.js.es6 @@ -254,8 +254,12 @@ export default Ember.Component.extend({ _syncEditorAndPreviewScroll($input, $preview, scrollMap) { let scrollTop; + const inputHeight = $input.height(); + const inputScrollHeight = $input[0].scrollHeight; + const inputClientHeight = $input[0].clientHeight; + const scrollable = inputScrollHeight > inputClientHeight; - if (($input.height() + $input.scrollTop() + 100) > $input[0].scrollHeight) { + if (scrollable && ((inputHeight + $input.scrollTop() + 100) > inputScrollHeight)) { scrollTop = $preview[0].scrollHeight; } else { const lineHeight = parseFloat($input.css('line-height'));