8
0
Просмотр исходного кода

Fixed case of optional name of position.

Kuba Niegowski 5 лет назад
Родитель
Сommit
de7796f8f8

+ 8 - 2
packages/ckeditor5-utils/src/dom/position.js

@@ -131,9 +131,15 @@ export function getOptimalPosition( { element, target, positions, limiter, fitIn
 // @param {utils/dom/rect~Rect} elementRect A rect of positioned element.
 // @returns {Array|null} An array containing position name and its Rect (or null if position should be ignored).
 function getPositionNameAndRect( position, targetRect, elementRect ) {
-	const { left, top, name } = position( targetRect, elementRect ) || {};
+	const positionData = position( targetRect, elementRect );
 
-	return name ? [ name, elementRect.clone().moveTo( left, top ) ] : null;
+	if ( !positionData ) {
+		return null;
+	}
+
+	const { left, top, name } = positionData;
+
+	return [ name, elementRect.clone().moveTo( left, top ) ];
 }
 
 // For a given array of positioning functions, returns such that provides the best

+ 1 - 1
packages/ckeditor5-widget/src/utils.js

@@ -374,7 +374,7 @@ export function viewToModelPositionOutsideModelElement( model, viewElementMatche
  *
  * @param {module:utils/dom/rect~Rect} widgetRect A rect of the widget.
  * @param {module:utils/dom/rect~Rect} balloonRect A rect of the balloon.
- * @returns {module:utils/dom/position~Position}
+ * @returns {module:utils/dom/position~Position|null}
  */
 export function centeredBalloonPositionForLongWidgets( widgetRect, balloonRect ) {
 	const viewportRect = new Rect( global.window );