Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix: border auxiliary is unexpectedly cleared after the merge cell is hidden (#3358)

lumixc11c324bfb74
diff --git a/packages/engine-render/src/components/sheets/spreadsheet.ts b/packages/engine-render/src/components/sheets/spreadsheet.ts
index dd47f1ae83..713679c449 100644
--- a/packages/engine-render/src/components/sheets/spreadsheet.ts
+++ b/packages/engine-render/src/components/sheets/spreadsheet.ts
@@ -545,7 +545,7 @@ export class Spreadsheet extends SheetComponent {
return;
}
- const { rowColumnSegment, dataMergeCache, overflowCache, showGridlines } = spreadsheetSkeleton;
+ const { rowColumnSegment, dataMergeCache: mergeCellRanges, overflowCache, showGridlines } = spreadsheetSkeleton;
const { startRow, endRow, startColumn, endColumn } = rowColumnSegment;
if (!spreadsheetSkeleton || showGridlines === BooleanNumber.FALSE || this._forceDisableGridlines) {
return;
@@ -597,6 +597,7 @@ export class Spreadsheet extends SheetComponent {
ctx.closePathByEnv();
ctx.stroke();
+ //#region draw horizontal lines
for (let r = rowStart; r <= rowEnd; r++) {
if (r < 0 || r > rowHeightAccumulationLength - 1) {
continue;
@@ -608,6 +609,7 @@ export class Spreadsheet extends SheetComponent {
ctx.closePathByEnv();
ctx.stroke();
}
+ //#endregion
for (let c = columnStart; c <= columnEnd; c++) {
if (c < 0 || c > columnWidthAccumulationLength - 1) {
@@ -620,49 +622,14 @@ export class Spreadsheet extends SheetComponent {
ctx.closePathByEnv();
ctx.stroke();
}
- // console.log('xx2', scaleX, scaleY, columnTotalWidth, rowTotalHeight, rowHeightAccumulation, columnWidthAccumulation);
+ //#endregion
- // border?.forValue((rowIndex, columnIndex, borderCaches) => {
- // if (!borderCaches) {
- // return true;
- // }
+ // clear line of merge cell
+ this._clearRectangle(ctx, rowHeightAccumulation, columnWidthAccumulation, mergeCellRanges);
- // const cellInfo = spreadsheetSkeleton.getCellByIndexWithNoHeader(rowIndex, columnIndex);
-
- // let { startY, endY, startX, endX } = cellInfo;
- // const { isMerged, isMergedMainCell, mergeInfo } = cellInfo;
-
- // if (isMerged) {
- // return true;
- // }
-
- // if (isMergedMainCell) {
- // startY = mergeInfo.startY;
- // endY = mergeInfo.endY;
- // startX = mergeInfo.startX;
- // endX = mergeInfo.endX;
- // }
-
- // if (!(mergeInfo.startRow >= rowStart && mergeInfo.endRow <= rowEnd)) {
- // return true;
- // }
-
- // for (const key in borderCaches) {
- // const { type } = borderCaches[key] as BorderCacheItem;
-
- // clearLineByBorderType(ctx, type, { startX, startY, endX, endY });
- // }
- // });
-
- // Clearing the dashed line issue caused by overlaid auxiliary lines and strokes
- // merge cell
- this._clearRectangle(ctx, rowHeightAccumulation, columnWidthAccumulation, dataMergeCache);
-
- // overflow cell
+ // clear line of overflow cell
this._clearRectangle(ctx, rowHeightAccumulation, columnWidthAccumulation, overflowCache.toNativeArray());
- // this._clearBackground(ctx, backgroundPositions);
-
ctx.restore();
}
@@ -673,20 +640,20 @@ export class Spreadsheet extends SheetComponent {
ctx: UniverRenderingContext2D,
rowHeightAccumulation: number[],
columnWidthAccumulation: number[],
- dataMergeCache?: IRange[]
+ cellRanges?: IRange[]
) {
- if (dataMergeCache == null) {
+ if (cellRanges == null) {
return;
}
- for (const dataCache of dataMergeCache) {
- const { startRow, endRow, startColumn, endColumn } = dataCache;
+ for (const range of cellRanges) {
+ const { startRow, endRow, startColumn, endColumn } = range;
- const startY = rowHeightAccumulation[startRow - 1] || 0;
- const endY = rowHeightAccumulation[endRow] || rowHeightAccumulation[rowHeightAccumulation.length - 1];
+ const startY = rowHeightAccumulation[startRow - 1] ?? 0;
+ const endY = rowHeightAccumulation[endRow] ?? rowHeightAccumulation[rowHeightAccumulation.length - 1];
- const startX = columnWidthAccumulation[startColumn - 1] || 0;
+ const startX = columnWidthAccumulation[startColumn - 1] ?? 0;
const endX =
- columnWidthAccumulation[endColumn] || columnWidthAccumulation[columnWidthAccumulation.length - 1];
+ columnWidthAccumulation[endColumn] ?? columnWidthAccumulation[columnWidthAccumulation.length - 1];
ctx.clearRectByPrecision(startX, startY, endX - startX, endY - startY);
diff --git a/packages/engine-render/src/shape/rect.ts b/packages/engine-render/src/shape/rect.ts
index 5ad8251019..3aa16ecc3b 100644
--- a/packages/engine-render/src/shape/rect.ts
+++ b/packages/engine-render/src/shape/rect.ts
@@ -14,58 +14,82 @@
* limitations under the License.
*/
-import { type IKeyValue, Rectangle } from '@univerjs/core';
+import type { IKeyValue, Nullable } from '@univerjs/core';
import type { UniverRenderingContext } from '../context';
-import type { IViewportInfo } from '../basics/vector2';
import { ObjectType } from '../base-object';
import type { IShapeProps } from './shape';
import { Shape } from './shape';
export interface IRectProps extends IShapeProps {
radius?: number;
+ visualHeight?: number;
+ visualWidth?: number;
}
export const RECT_OBJECT_ARRAY = ['radius'];
export class Rect<T extends IRectProps = IRectProps> extends Shape<T> {
- private _radius: number = 0;
-
override objectType = ObjectType.RECT;
+ private _radius: number = 0;
+ /**
+ * For rendering, in many case object size is bigger than visual size for better user interaction.
+ */
+ private _visualHeight: Nullable<number>;
+ private _visualWidth: Nullable<number>;
+
constructor(key?: string, props?: T) {
super(key, props);
if (props?.radius) {
this._radius = props.radius;
}
+ if (props?.visualHeight) {
+ this._visualHeight = props.visualHeight;
+ }
+ if (props?.visualWidth) {
+ this._visualWidth = props.visualWidth;
+ }
+ }
+
+ get visualHeight(): Nullable<number> {
+ return this._visualHeight;
+ }
+
+ get visualWidth(): Nullable<number> {
+ return this._visualWidth;
}
get radius() {
return this._radius;
}
- static override drawWith(ctx: UniverRenderingContext, props: IRectProps | Rect) {
- let { radius, left, top, width, height } = props;
+ static override drawWith(ctx: UniverRenderingContext, props: IRectProps) {
+ let { radius, width, height } = props;
radius = radius ?? 0;
width = width ?? 0;
height = height ?? 0;
- left = left ?? 0;
- top = top ?? 0;
+ ctx.save();
ctx.beginPath();
if (props.strokeDashArray) {
ctx.setLineDash(props.strokeDashArray);
- } else {
- // only dashrect needs top & left(which relative to topleft of viewport)
- top = 0;
- left = 0;
+ }
+
+ if (props.visualHeight) {
+ ctx.translate(0, (height - (props.visualHeight || 0)) / 2);
+ height = props.visualHeight;
+ }
+ if (props.visualWidth) {
+ ctx.translate((width - (props.visualWidth || 0)) / 2, 0);
+ width = props.visualWidth;
}
if (!radius) {
- // simple rect - don't bother doing all that complicated maths stuff.
- ctx.rect(left, top, width, height);
+ // transform of this rect has been handled in shape@render
+ ctx.rect(0, 0, width, height);
} else {
let topLeft = 0;
let topRight = 0;
@@ -86,6 +110,8 @@ export class Rect<T extends IRectProps = IRectProps> extends Shape<T> {
ctx.closePath();
this._renderPaintInOrder(ctx, props);
+
+ ctx.restore();
}
override toJson() {
@@ -102,36 +128,7 @@ export class Rect<T extends IRectProps = IRectProps> extends Shape<T> {
};
}
- protected override _draw(ctx: UniverRenderingContext, viewportInfo?: IViewportInfo) {
- const { radius, paintFirst, stroke, strokeWidth, fill, strokeScaleEnabled, fillRule, strokeLineCap, strokeDashOffset, strokeLineJoin, strokeMiterLimit, strokeDashArray } = this;
- if (!strokeDashArray) {
- Rect.drawWith(ctx, this);
- } else {
- const parentTrans = this.getParent().transform;
- // group.transform contains startXY
- // selection-shape@_updateControl --> this.selectionShape.translate(startX, startY);
-
- // startXY comes from selecitonModel
- // const { startX, startY, endX, endY } = this._selectionModel;
- const startX = parentTrans.getMatrix()[4];
- const startY = parentTrans.getMatrix()[5];
- const endX = startX + this.width;
- const endY = startY + this.height;
- const rect = { left: startX, top: startY, right: endX, bottom: endY };
- let { left, top, right, bottom } = rect;
-
- let width = right - left;
- let height = bottom - top;
- if (viewportInfo && Rectangle.hasIntersectionBetweenTwoRect(rect, viewportInfo.cacheBound)) {
- const intersectRect = Rectangle.getIntersectionBetweenTwoRect(rect, viewportInfo.cacheBound)!;
- left = intersectRect.left - startX;
- top = intersectRect.top - startY;
- right = intersectRect.right;
- bottom = intersectRect.bottom;
- width = intersectRect.width;
- height = intersectRect.height;
- }
- Rect.drawWith(ctx, { ...{ radius, width, height, paintFirst, stroke, strokeWidth, fill, strokeScaleEnabled, fillRule, strokeLineCap, strokeDashOffset, strokeLineJoin, strokeMiterLimit, strokeDashArray }, ...{ width, height, left, top } });
- }
+ protected override _draw(ctx: UniverRenderingContext) {
+ Rect.drawWith(ctx, this as IRectProps);
}
}
diff --git a/packages/sheets-ui/src/controllers/render-controllers/header-move.render-controller.ts b/packages/sheets-ui/src/controllers/render-controllers/header-move.render-controller.ts
index 0cd828bb73..2caa83c99a 100644
--- a/packages/sheets-ui/src/controllers/render-controllers/header-move.render-controller.ts
+++ b/packages/sheets-ui/src/controllers/render-controllers/header-move.render-controller.ts
@@ -48,15 +48,10 @@ import { getCoordByOffset } from '../utils/component-tools';
import { matchedSelectionByRowColIndex } from '../utils/selections-tools';
const HEADER_MOVE_CONTROLLER_BACKGROUND = '__SpreadsheetHeaderMoveControllerBackground__';
-
const HEADER_MOVE_CONTROLLER_LINE = '__SpreadsheetHeaderMoveControllerShapeLine__';
-
const HEADER_MOVE_CONTROLLER_BACKGROUND_FILL = 'rgba(0, 0, 0, 0.1)';
-
const HEADER_MOVE_CONTROLLER_LINE_FILL = 'rgb(119, 119, 119)';
-
const HEADER_MOVE_CONTROLLER_LINE_SIZE = 4;
-
export const HEADER_MOVE_PERMISSION_CHECK = createInterceptorKey<boolean, IRange>('headerMovePermissionCheck');
export class HeaderMoveRenderController extends Disposable implements IRenderModule {
diff --git a/packages/sheets-ui/src/services/selection/mobile-selection-shape.ts b/packages/sheets-ui/src/services/selection/mobile-selection-shape.ts
index 6a9d0204f9..1a77679009 100644
--- a/packages/sheets-ui/src/services/selection/mobile-selection-shape.ts
+++ b/packages/sheets-ui/src/services/selection/mobile-selection-shape.ts
@@ -32,14 +32,6 @@ export class MobileSelectionControl extends SelectionControl {
* bottomRight controlPointer, it is not visible, just transparent, for handling event.
*/
private _fillControlBottomRight: Rect | null;
- /**
- * a very small visible point, placed in control pointer
- */
- private _fillControlTopLeftInner: Rect | null;
- /**
- * a very small visible point, placed in control pointer
- */
- private _fillControlBottomRightInner: Rect | null;
constructor(
protected override _scene: Scene,
@@ -60,37 +52,24 @@ export class MobileSelectionControl extends SelectionControl {
const stroke = defaultStyle.stroke!;
const AutofillStroke = defaultStyle.AutofillStroke!;
const zIndex = this.zIndex;
- const RectCtor = Rect;
- // if (this._rangeType === RANGE_TYPE.ROW || this._rangeType === RANGE_TYPE.COLUMN) {
- // RectCtor = FloatRect;
- // }
// @transformControlPoint takes care of left & top
- this._fillControlTopLeft = new RectCtor(SELECTION_MANAGER_KEY.fillTopLeft + zIndex, {
+ this._fillControlTopLeft = new Rect(SELECTION_MANAGER_KEY.fillTopLeft + zIndex, {
zIndex: zIndex + 2,
width: expandCornerSize,
height: expandCornerSize,
radius: expandCornerSize / 2,
+ visualWidth: expandCornerInnerSize,
+ visualHeight: expandCornerInnerSize,
strokeWidth: AutofillStrokeWidth,
});
- this._fillControlTopLeftInner = new RectCtor(SELECTION_MANAGER_KEY.fillTopLeftInner + zIndex, {
- zIndex: zIndex + 1,
- width: expandCornerInnerSize,
- height: expandCornerInnerSize,
- radius: expandCornerInnerSize / 2,
- strokeWidth: AutofillStrokeWidth,
- });
- this._fillControlBottomRight = new RectCtor(SELECTION_MANAGER_KEY.fillBottomRight + zIndex, {
+
+ this._fillControlBottomRight = new Rect(SELECTION_MANAGER_KEY.fillBottomRight + zIndex, {
zIndex: zIndex + 2,
width: expandCornerSize,
height: expandCornerSize,
radius: expandCornerSize / 2,
- strokeWidth: AutofillStrokeWidth,
- });
- this._fillControlBottomRightInner = new RectCtor(SELECTION_MANAGER_KEY.fillBottomRightInner + zIndex, {
- zIndex: zIndex + 1,
- width: expandCornerInnerSize,
- height: expandCornerInnerSize,
- radius: expandCornerInnerSize / 2,
+ visualHeight: expandCornerInnerSize,
+ visualWidth: expandCornerInnerSize,
strokeWidth: AutofillStrokeWidth,
});
@@ -99,14 +78,13 @@ export class MobileSelectionControl extends SelectionControl {
stroke: AutofillStroke,
strokeScaleEnabled: false,
};
- this._fillControlTopLeftInner!.setProps({ ...fillProps });
- this._fillControlBottomRightInner!.setProps({ ...fillProps });
- // for test
- // this.fillControlTopLeft!.setProps({ ...fillProps, ...{ fill: 'red' } });
- // this.fillControlBottomRight!.setProps({ ...fillProps, ...{ fill: 'black' } });
+ this._fillControlTopLeft!.setProps({ ...fillProps });
+ this._fillControlBottomRight!.setProps({ ...fillProps });
// put into scene
- const objs = [this._fillControlTopLeft, this._fillControlBottomRight, this._fillControlTopLeftInner, this._fillControlBottomRightInner] as BaseObject[];
+ const objs = [
+ this._fillControlTopLeft, this._fillControlBottomRight,
+ ] as BaseObject[];
// do not use this.model.rangeType, model has not been initialized yet
switch (this._rangeType) {
@@ -179,13 +157,9 @@ export class MobileSelectionControl extends SelectionControl {
this.fillControlTopLeft!.show();
this.fillControlBottomRight!.show();
- this._fillControlTopLeftInner!.show();
- this._fillControlBottomRightInner!.show();
} else {
this.fillControlTopLeft?.hide();
this.fillControlBottomRight?.hide();
- this._fillControlTopLeftInner?.hide();
- this._fillControlBottomRightInner?.hide();
}
}
@@ -206,15 +180,13 @@ export class MobileSelectionControl extends SelectionControl {
* @param sheetContentWidth
* @param sheetContentHeight max sheet content height, for very short sheet, control pointer shoud not out of sheet
*/
- // eslint-disable-next-line max-lines-per-function
+
transformControlPoint(viewportScrollX: number = 0, viewportScrollY: number = 0, sheetContentWidth: number = 0, sheetContentHeight: number = 0): void {
const style = this.currentStyle!;
const rangeType = this.selectionModel.rangeType;
- const expandCornerSizeInner = style.expandCornerSize! / 4;
const expandCornerSize = style.expandCornerSize!;
const { startX, startY, endX, endY } = this.selectionModel;
- // const scene = this.getScene();
const viewportSizeInfo = this.getViewportMainScrollInfo();
const viewportW = viewportSizeInfo.width;
const viewportH = viewportSizeInfo.height;
@@ -229,20 +201,11 @@ export class MobileSelectionControl extends SelectionControl {
left: endX - startX - expandCornerSize / 2,
top: endY - startY - expandCornerSize / 2,
});
- this._fillControlTopLeftInner!.transformByState({
- left: -expandCornerSizeInner / 2,
- top: -expandCornerSizeInner / 2,
- });
- this._fillControlBottomRightInner!.transformByState({
- left: endX - startX - expandCornerSizeInner / 2,
- top: endY - startY - expandCornerSizeInner / 2,
- });
break;
case RANGE_TYPE.ROW: {
const left = Math.min(viewportW / 2 + viewportScrollX, sheetContentWidth);
const controlLeft = -expandCornerSize / 2 + left;
- const innerLeft = -expandCornerSizeInner / 2 + left;
this.fillControlTopLeft!.transformByState({
left: controlLeft,
top: -expandCornerSize / 2,
@@ -251,21 +214,12 @@ export class MobileSelectionControl extends SelectionControl {
left: controlLeft,
top: -expandCornerSize / 2 + endY - startY,
});
- this._fillControlTopLeftInner!.transformByState({
- left: innerLeft,
- top: -expandCornerSizeInner / 2,
- });
- this._fillControlBottomRightInner!.transformByState({
- left: innerLeft,
- top: -expandCornerSizeInner / 2 + endY - startY,
- });
}
break;
case RANGE_TYPE.COLUMN:
{
const top = Math.min(+viewportH / 2 + viewportScrollY, sheetContentHeight);
const controlTop = -expandCornerSize / 2 + top;
- const innerTop = -expandCornerSizeInner / 2 + top;
this.fillControlTopLeft!.transformByState({
left: -expandCornerSize / 2,
@@ -275,14 +229,6 @@ export class MobileSelectionControl extends SelectionControl {
left: -expandCornerSize / 2 + endX - startX,
top: controlTop,
});
- this._fillControlTopLeftInner!.transformByState({
- left: -expandCornerSizeInner / 2,
- top: innerTop,
- });
- this._fillControlBottomRightInner!.transformByState({
- left: -expandCornerSizeInner / 2 + endX - startX,
- top: innerTop,
- });
}
break;
default:
diff --git a/packages/sheets-ui/src/services/selection/selection-shape.ts b/packages/sheets-ui/src/services/selection/selection-shape.ts
index 2b27678178..c738b40e61 100644
--- a/packages/sheets-ui/src/services/selection/selection-shape.ts
+++ b/packages/sheets-ui/src/services/selection/selection-shape.ts
@@ -40,6 +40,7 @@ export enum SELECTION_MANAGER_KEY {
backgroundMiddleRight = '__SpreadsheetSelectionBackgroundControlMiddleRight__',
backgroundBottom = '__SpreadsheetSelectionBackgroundControlBottom__',
fill = '__SpreadsheetSelectionFillControl__',
+
// fillTopLeft & fillBottomRight are used for mobile selection
fillTopLeft = '__SpreadsheetSelectionFillControlTopLeft__',
fillBottomRight = '__SpreadsheetSelectionFillControlBottomRight__',
@@ -75,10 +76,10 @@ const SELECTION_TITLE_HIGHLIGHT_ALPHA = 0.3;
* The main selection canvas component, includes leftControl,rightControl,topControl,bottomControl,backgroundControlTop,backgroundControlMiddleLeft,backgroundControlMiddleRight,backgroundControlBottom,fillControl
*/
export class SelectionControl extends Disposable {
- private _leftControl!: Rect;
- private _rightControl!: Rect;
- private _topControl!: Rect;
- private _bottomControl!: Rect;
+ private _leftBorder!: Rect;
+ private _rightBorder!: Rect;
+ private _topBorder!: Rect;
+ private _bottomBorder!: Rect;
private _backgroundControlTop!: Rect;
private _backgroundControlBottom!: Rect;
@@ -98,6 +99,7 @@ export class SelectionControl extends Disposable {
private _columnHeaderGroup!: Group;
// private _columnHeaderHighlight!: Rect;
+ // for ref selection
private _topLeftWidget!: Rect;
private _topCenterWidget!: Rect;
private _topRightWidget!: Rect;
@@ -107,7 +109,7 @@ export class SelectionControl extends Disposable {
private _bottomCenterWidget!: Rect;
private _bottomRightWidget!: Rect;
- private _dashRect!: Rect;
+ private _dashedRect!: Rect;
protected _selectionModel!: SelectionRenderModel;
@@ -161,19 +163,19 @@ export class SelectionControl extends Disposable {
}
get leftControl(): Rect {
- return this._leftControl;
+ return this._leftBorder;
}
get rightControl(): Rect {
- return this._rightControl;
+ return this._rightBorder;
}
get topControl(): Rect {
- return this._topControl;
+ return this._topBorder;
}
get bottomControl(): Rect {
- return this._bottomControl;
+ return this._bottomBorder;
}
get fillControl(): Rect {
@@ -268,8 +270,8 @@ export class SelectionControl extends Disposable {
this._defaultStyle = style;
}
- get dashRect(): Rect {
- return this._dashRect;
+ get dashedRect(): Rect {
+ return this._dashedRect;
}
get currentStyle(): Nullable<ISelectionStyle> {
@@ -401,11 +403,11 @@ export class SelectionControl extends Disposable {
});
if (strokeDash === null || strokeDash === undefined) {
- this.dashRect.hide();
+ this.dashedRect.hide();
this._stopAntLineAnimation();
} else {
const dashRectBorderWidth = currentStyle.strokeWidth * 2 / scale;
- this.dashRect.transformByState({
+ this.dashedRect.transformByState({
height: endY - startY,
width: endX - startX,
strokeWidth: dashRectBorderWidth,
@@ -413,7 +415,7 @@ export class SelectionControl extends Disposable {
top: -dashRectBorderWidth / 2 + fixOnePixelBlurOffset,
});
- this.dashRect.setProps({
+ this.dashedRect.setProps({
strokeDashArray: [0, strokeDash / scale],
});
@@ -423,7 +425,7 @@ export class SelectionControl extends Disposable {
this._startAntLineAnimation();
}
- this.dashRect.show();
+ this.dashedRect.show();
}
if (hasAutoFill === true && !this._hasWidgets(widgets)) {
@@ -515,10 +517,10 @@ export class SelectionControl extends Disposable {
// eslint-disable-next-line complexity
override dispose(): void {
- this._leftControl?.dispose();
- this._rightControl?.dispose();
- this._topControl?.dispose();
- this._bottomControl?.dispose();
+ this._leftBorder?.dispose();
+ this._rightBorder?.dispose();
+ this._topBorder?.dispose();
+ this._bottomBorder?.dispose();
this._backgroundControlTop?.dispose();
this._backgroundControlMiddleLeft?.dispose();
this._backgroundControlMiddleRight?.dispose();
@@ -615,19 +617,19 @@ export class SelectionControl extends Disposable {
this._selectionModel = new SelectionRenderModel();
const zIndex = this._zIndex;
- this._leftControl = new Rect(SELECTION_MANAGER_KEY.left + zIndex, {
+ this._leftBorder = new Rect(SELECTION_MANAGER_KEY.left + zIndex, {
zIndex,
});
- this._rightControl = new Rect(SELECTION_MANAGER_KEY.right + zIndex, {
+ this._rightBorder = new Rect(SELECTION_MANAGER_KEY.right + zIndex, {
zIndex,
});
- this._topControl = new Rect(SELECTION_MANAGER_KEY.top + zIndex, {
+ this._topBorder = new Rect(SELECTION_MANAGER_KEY.top + zIndex, {
zIndex,
});
- this._bottomControl = new Rect(SELECTION_MANAGER_KEY.bottom + zIndex, {
+ this._bottomBorder = new Rect(SELECTION_MANAGER_KEY.bottom + zIndex, {
zIndex,
});
@@ -658,7 +660,7 @@ export class SelectionControl extends Disposable {
// That weird, new Dashedrect should called when strokeDash. not every selectionControl need dashedRect.
// strokeDash === null || strokeDash === undefined ---> _dashRect.hide()
- this._dashRect = new DashedRect(SELECTION_MANAGER_KEY.dash + zIndex, {
+ this._dashedRect = new DashedRect(SELECTION_MANAGER_KEY.dash + zIndex, {
zIndex: zIndex + 2,
evented: false,
stroke: '#fff',
@@ -666,10 +668,10 @@ export class SelectionControl extends Disposable {
const shapes = [
this._fillControl,
- this._leftControl, this._rightControl, this._topControl, this._bottomControl,
+ this._leftBorder, this._rightBorder, this._topBorder, this._bottomBorder,
this._backgroundControlTop, this._backgroundControlMiddleLeft,
this._backgroundControlMiddleRight, this._backgroundControlBottom,
- this._dashRect,
+ this._dashedRect,
];
this._widgetRects = this._initialWidget();
@@ -1070,7 +1072,7 @@ export class SelectionControl extends Disposable {
if (this._antLineOffset > 160 / scale) {
this._antLineOffset = 0;
}
- this.dashRect.setProps({
+ this.dashedRect.setProps({
strokeDashOffset: -this._antLineOffset,
});
this._antRequestNewFrame = requestNewFrame(() => {
diff --git a/packages/sheets/src/services/selections/selection-manager.service.ts b/packages/sheets/src/services/selections/selection-manager.service.ts
index 1ff4e90f37..f02fb4d29a 100644
--- a/packages/sheets/src/services/selections/selection-manager.service.ts
+++ b/packages/sheets/src/services/selections/selection-manager.service.ts
@@ -248,7 +248,7 @@ export class WorkbookSelections extends Disposable {
* @param selectionDatas
* @param type
*/
- setSelections(sheetId: string, selectionDatas: ISelectionWithStyle[], type: SelectionMoveType): void {
+ setSelections(sheetId: string, selectionDatas: ISelectionWithStyle[] = [], type: SelectionMoveType): void {
// selectionDatas should not be same variable as this._worksheetSelections !!!
// but there are some place get selection from this._worksheetSelections and set selectionDatas(2nd parameter of this function ) cause selectionDatas is always []
// see univer/pull/2909