Prevent block decorations from mistakenly wrapping during measurements

Before rendering block decorations, we read their heights by putting
them into a special div called `blockDecorationMeasurementsArea`.

Previously, this div was not explicitly sized, which was causing
decorations to wrap while being measured but not when actually rendering
them.

This commit fixes this inconsistency by explicitly styling the
measurement area so that it has the same width as the component scroll
width.
This commit is contained in:
Antonio Scandurra
2017-06-13 12:30:11 +02:00
parent 032dcd8bf4
commit 0a46c9ad7b
2 changed files with 11 additions and 1 deletions

View File

@@ -2035,6 +2035,15 @@ describe('TextEditorComponent', () => {
expect(item6.previousSibling).toBe(lineNodeForScreenRow(component, 12))
})
it('bases the width of the block decoration measurement area on the editor scroll width', async () => {
const {component, element} = buildComponent({autoHeight: false, width: 150})
expect(component.refs.blockDecorationMeasurementArea.offsetWidth).toBe(component.getScrollWidth())
element.style.width = '800px'
await component.getNextUpdatePromise()
expect(component.refs.blockDecorationMeasurementArea.offsetWidth).toBe(component.getScrollWidth())
})
function createBlockDecorationAtScreenRow(editor, screenRow, {height, margin, position}) {
const marker = editor.markScreenPosition([screenRow, 0], {invalidate: 'never'})
const item = document.createElement('div')

View File

@@ -678,7 +678,8 @@ class TextEditorComponent {
style: {
contain: 'strict',
position: 'absolute',
visibility: 'hidden'
visibility: 'hidden',
width: this.getScrollWidth() + 'px'
}
})
}