Преглед изворни кода

Internal: Fixed a case where focusing widget, blurring editor and refocusing widget once again would not mark selection properly.

Marek Lewandowski пре 6 година
родитељ
комит
715e406a20
1 измењених фајлова са 13 додато и 1 уклоњено
  1. 13 1
      packages/ckeditor5-engine/src/view/renderer.js

+ 13 - 1
packages/ckeditor5-engine/src/view/renderer.js

@@ -803,8 +803,20 @@ export default class Renderer {
 	 */
 	_fakeSelectionNeedsUpdate( domRoot ) {
 		const container = this._fakeSelectionContainer;
+		const domSelection = domRoot.ownerDocument.getSelection();
 
-		return !container || container.parentElement != domRoot || container.textContent !== this.selection.fakeSelectionLabel;
+		// Selection fakeselection needs to be updated if there's no fake selection container, or container
+		// currently sits in different root.
+		if ( !container || container.parentElement != domRoot ) {
+			return false;
+		}
+
+		// Make sure that the selection actually is within the fake selection.
+		if ( !domSelection.anchorNode.isSameNode( container ) ) {
+			return true;
+		}
+
+		return container.textContent !== this.selection.fakeSelectionLabel;
 	}
 
 	/**