Răsfoiți Sursa

The model selectionPostFixer() should not alter the selection if a "fixed" range is the same as the original.

Aleksander Nowodzinski 5 ani în urmă
părinte
comite
e8c5e73c62

+ 4 - 1
packages/ckeditor5-engine/src/model/utils/selection-post-fixer.js

@@ -82,7 +82,10 @@ function selectionPostFixer( writer, model ) {
 		// Those ranges might overlap but will be corrected later.
 		const correctedRange = tryFixingRange( modelRange, schema );
 
-		if ( correctedRange ) {
+		// It may happen that a new range is returned but in fact it has the same positions as the original
+		// range anyway. If this branch was not discarded, a new selection would be set and that, for instance,
+		// would destroy the selection' attributes.
+		if ( correctedRange && !correctedRange.isEqual( modelRange ) ) {
 			ranges.push( correctedRange );
 			wasFixed = true;
 		} else {