From df4116d4aa55635dedf18d87dc7c22a224183d4d Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 5 May 2017 18:18:30 +0200 Subject: [PATCH] Fix clicking past the content height Signed-off-by: Nathan Sobo --- spec/text-editor-component-spec.js | 10 ++++++++++ src/text-editor-component.js | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/spec/text-editor-component-spec.js b/spec/text-editor-component-spec.js index e13086961..006f2859e 100644 --- a/spec/text-editor-component-spec.js +++ b/spec/text-editor-component-spec.js @@ -114,6 +114,16 @@ describe('TextEditorComponent', () => { } }) + it('makes the content at least as tall as the scroll container client height', async () => { + const {component, element, editor} = buildComponent({text: 'a', height: 100}) + expect(component.refs.content.offsetHeight).toBe(100) + + editor.setText('a\n'.repeat(30)) + await component.getNextUpdatePromise() + expect(component.refs.content.offsetHeight).toBeGreaterThan(100) + expect(component.refs.content.offsetHeight).toBe(component.getContentHeight()) + }) + it('honors the scrollPastEnd option by adding empty space equivalent to the clientHeight to the end of the content area', async () => { const {component, element, editor} = buildComponent({autoHeight: false, autoWidth: false}) const {scrollContainer} = component.refs diff --git a/src/text-editor-component.js b/src/text-editor-component.js index fcc35bc55..87f66875a 100644 --- a/src/text-editor-component.js +++ b/src/text-editor-component.js @@ -2435,8 +2435,10 @@ class TextEditorComponent { 3 * this.getLineHeight(), this.getScrollContainerClientHeight() - (3 * this.getLineHeight()) ) - } else { + } else if (this.props.model.getAutoHeight()) { return this.getContentHeight() + } else { + return Math.max(this.getContentHeight(), this.getScrollContainerClientHeight()) } }