Browse Source

Fixed: In `view.Renderer#render` make sure that inline filler is created before selection is updated (so selection do not end up before filler element).

Szymon Cofalik 8 years ago
parent
commit
2354d31dd7

+ 7 - 7
packages/ckeditor5-engine/src/view/renderer.js

@@ -212,13 +212,6 @@ export default class Renderer {
 			this._updateChildren( element, { inlineFillerPosition } );
 		}
 
-		this._updateSelection();
-		this._updateFocus();
-
-		this.markedTexts.clear();
-		this.markedAttributes.clear();
-		this.markedChildren.clear();
-
 		// Check whether inline filler is required and where it really is in DOM. At this point in most cases it should
 		// be in DOM, but not always. For example, if inline filler was deep in created DOM structure, it will not be created.
 		// Similarly, if it was removed at the beginning of this function and then neither text nor children were updated,
@@ -239,6 +232,13 @@ export default class Renderer {
 			// There is no filler needed.
 			this._inlineFiller = null;
 		}
+
+		this._updateSelection();
+		this._updateFocus();
+
+		this.markedTexts.clear();
+		this.markedAttributes.clear();
+		this.markedChildren.clear();
 	}
 
 	/**

+ 4 - 0
packages/ckeditor5-engine/tests/view/renderer.js

@@ -1249,6 +1249,10 @@ describe( 'Renderer', () => {
 			renderer.render();
 
 			expect( domRoot.innerHTML.indexOf( INLINE_FILLER ) ).not.to.equal( -1 );
+
+			const domSelection = document.getSelection();
+
+			expect( domSelection.getRangeAt( 0 ).startOffset ).to.equal( 7 ); // After inline filler.
 		} );
 
 		it( 'should handle focusing element', () => {