Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move range selection not showing when dragging a selection #4082

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,10 @@ export class SheetSelectionRenderService extends BaseSelectionRenderService impl
}

private _initSelectionChangeListener(): void {
// only ref selection need this,
// this.disposeWithMe(merge(this._workbookSelections.selectionMoveEnd$, this._workbookSelections.selectionSet$).subscribe((selectionWithStyleList) => {
// // this._reset();
// // for (const selectionWithStyle of selectionWithStyleList) {
// // this._addSelectionControlByModelData(selectionWithStyle);
// // }
// }));
// normal selection: after dragging selection(move end)
this.disposeWithMe(this._workbookSelections.selectionMoveEnd$.subscribe((selectionWithStyleList) => {
this.resetSelectionsByModelData(selectionWithStyleList);
}));
}

private _initUserActionSyncListener(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type { SelectionControl } from './selection-control';
import { SheetSkeletonManagerService } from '../sheet-skeleton-manager.service';
import { ISheetSelectionRenderService } from './base-selection-render.service';
import { genNormalSelectionStyle, RANGE_FILL_PERMISSION_CHECK, RANGE_MOVE_PERMISSION_CHECK } from './const';
import { attachSelectionWithCoord } from './util';
import { attachPrimaryWithCoord, attachSelectionWithCoord } from './util';

const HELPER_SELECTION_TEMP_NAME = '__SpreadsheetHelperSelectionTempRect';

Expand Down Expand Up @@ -67,6 +67,9 @@ export class SelectionShapeExtension {

private _scenePointerUpSub: Nullable<Subscription>;

/**
* The shadow selection under cursor when move whole selection control(for moving normal selection)
*/
private _helperSelection: Nullable<Rect>;

private _scrollTimer!: ScrollTimer;
Expand Down Expand Up @@ -240,33 +243,23 @@ export class SelectionShapeExtension {
style: null,
};
const selectionWithCoord = attachSelectionWithCoord(selection, this._skeleton);
// const startCell = this._skeleton.getNoMergeCellPositionByIndex(startRow, startColumn);
// const endCell = this._skeleton.getNoMergeCellPositionByIndex(endRow, endColumn);
// const startY = startCell?.startY || 0;
// const endY = endCell?.endY || 0;
// const startX = startCell?.startX || 0;
// const endX = endCell?.endX || 0;
const startCell = this._skeleton.getNoMergeCellPositionByIndex(startRow, startColumn);
const endCell = this._skeleton.getNoMergeCellPositionByIndex(endRow, endColumn);
const startY = startCell?.startY || 0;
const endY = endCell?.endY || 0;
const startX = startCell?.startX || 0;
const endX = endCell?.endX || 0;

// this._helperSelection?.transformByState({
// left: startX,
// top: startY,
// width: endX - startX,
// height: endY - startY,
// });
this._helperSelection?.transformByState({
left: startX,
top: startY,
width: endX - startX,
height: endY - startY,
});

// this._targetSelection = {
// startY,
// endY,
// startX,
// endX,
// startRow,
// endRow,
// startColumn,
// endColumn,
// };
// const primaryWithCoordAndMergeInfo = attachPrimaryWithCoord(this._skeleton, primaryCell);
// this._control.updateRange(this._targetSelection, primaryWithCoordAndMergeInfo);
this._control.updateRangeBySelectionWithCoord(selectionWithCoord);
this._targetSelection = { ...selectionWithCoord.rangeWithCoord };
const primaryWithCoordAndMergeInfo = attachPrimaryWithCoord(this._skeleton, primaryCell);
this._control.updateCurrCell(primaryWithCoordAndMergeInfo);
this._control.selectionMoving$.next(selectionWithCoord.rangeWithCoord);
}

Expand Down Expand Up @@ -583,7 +576,7 @@ export class SelectionShapeExtension {
const primaryCell = this._skeleton.getCellWithMergeInfoByIndex(startRow, startColumn);
const selectionWithStyle: ISelectionWithStyle = { range, primary: primaryCell, style: null };
const selectionRangeWithCoord = attachSelectionWithCoord(selectionWithStyle, this._skeleton);
this._targetSelection = selectionRangeWithCoord.rangeWithCoord;
this._targetSelection = { ...selectionRangeWithCoord.rangeWithCoord };
// const startCell = this._skeleton.getNoMergeCellPositionByIndex(finalStartRow, finalStartColumn);
// const endCell = this._skeleton.getNoMergeCellPositionByIndex(finalEndRow, finalEndColumn);

Expand Down
Loading