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: context menu should not clear selections (#2949)

Ran Luob5fcb55fdee4
diff --git a/packages/engine-render/src/components/docs/text-selection/convert-rect-range.ts b/packages/engine-render/src/components/docs/text-selection/convert-rect-range.ts
index c87bf6c65f..5e507fbd55 100644
--- a/packages/engine-render/src/components/docs/text-selection/convert-rect-range.ts
+++ b/packages/engine-render/src/components/docs/text-selection/convert-rect-range.ts
@@ -90,7 +90,7 @@ export function compareNodePositionInTable(a: INodePosition, b: INodePosition):
return false;
}
- return aCellCount < bCellCount;
+ return aCellCount <= bCellCount;
}
function firstGlyphInCellPage(cellPage: IDocumentSkeletonPage): Nullable<IDocumentSkeletonGlyph> {
diff --git a/packages/engine-render/src/components/docs/text-selection/text-selection-render-manager.ts b/packages/engine-render/src/components/docs/text-selection/text-selection-render-manager.ts
index 46b52b4fa2..7e07d7aa0b 100644
--- a/packages/engine-render/src/components/docs/text-selection/text-selection-render-manager.ts
+++ b/packages/engine-render/src/components/docs/text-selection/text-selection-render-manager.ts
@@ -497,14 +497,14 @@ export class TextSelectionRenderManager extends RxDisposable implements ITextSel
position.isBack = true;
}
- const textSelection = this._textSelectionInner$.value;
- if (startNode && evt.button === 2 && textSelection) {
+ const docSelection = this._textSelectionInner$.value;
+ if (startNode && evt.button === 2 && docSelection) {
const nodeCharIndex = this._docSkeleton?.findCharIndexByPosition(position);
- if (typeof nodeCharIndex === 'number' && textSelection.textRanges.some((textRange) => textRange.startOffset! <= nodeCharIndex && textRange.endOffset! > nodeCharIndex)) {
+ if (typeof nodeCharIndex === 'number' && docSelection.textRanges.some((textRange) => textRange.startOffset! <= nodeCharIndex && textRange.endOffset! > nodeCharIndex)) {
return;
}
- if (typeof nodeCharIndex === 'number' && textSelection.rectRanges.some((rectRange) => rectRange.startOffset! <= nodeCharIndex && rectRange.endOffset! >= nodeCharIndex)) {
+ if (typeof nodeCharIndex === 'number' && docSelection.rectRanges.some((rectRange) => rectRange.startOffset! <= nodeCharIndex && rectRange.endOffset! >= nodeCharIndex)) {
return;
}
}