Fix clicking past the content height

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Antonio Scandurra
2017-05-05 18:18:30 +02:00
parent edf1b7fb74
commit df4116d4aa
2 changed files with 13 additions and 1 deletions

View File

@@ -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

View File

@@ -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())
}
}