diff --git a/packages/s2-core/src/sheet-type/spread-sheet.ts b/packages/s2-core/src/sheet-type/spread-sheet.ts
index d15b114fb7..cefd7dc0df 100644
--- a/packages/s2-core/src/sheet-type/spread-sheet.ts
+++ b/packages/s2-core/src/sheet-type/spread-sheet.ts
@@ -744,15 +744,17 @@ export abstract class SpreadSheet extends EE {
...canvasConfig,
});
- this.updateContainerStyle();
+ this.setupContainerStyle();
}
- // canvas 需要设置为 块级元素, 不然和父元素有 5px 的高度差
- protected updateContainerStyle() {
+ protected setupContainerStyle() {
const canvas = this.getCanvasElement();
if (canvas) {
+ // canvas 需要设置为块级元素, 不然和父元素有 5px 的高度差
canvas.style.display = 'block';
+ // 避免双击 canvas 造成的外部文本选中
+ canvas.style.userSelect = 'none';
}
}
diff --git a/packages/s2-react/__tests__/unit/components/sheets/__snapshots__/index-spec.tsx.snap b/packages/s2-react/__tests__/unit/components/sheets/__snapshots__/index-spec.tsx.snap
index 3638528229..ec015974ae 100644
--- a/packages/s2-react/__tests__/unit/components/sheets/__snapshots__/index-spec.tsx.snap
+++ b/packages/s2-react/__tests__/unit/components/sheets/__snapshots__/index-spec.tsx.snap
@@ -96,7 +96,7 @@ exports[` Tests Render Tests should render editable sheet by sn
>
@@ -364,7 +364,7 @@ exports[` Tests Render Tests should render gridAnalysis sheet b
>
@@ -622,7 +622,7 @@ exports[` Tests Render Tests should render pivot sheet by snaps
>
@@ -880,7 +880,7 @@ exports[` Tests Render Tests should render strategy sheet by sn
>
@@ -1138,7 +1138,7 @@ exports[` Tests Render Tests should render table sheet by snaps
>
diff --git a/packages/s2-react/playground/index.tsx b/packages/s2-react/playground/index.tsx
index aa95421179..40d9ebf5af 100644
--- a/packages/s2-react/playground/index.tsx
+++ b/packages/s2-react/playground/index.tsx
@@ -1586,6 +1586,7 @@ function MainLayout() {
onDataCellContextMenu={logHandler(
'onDataCellContextMenu',
)}
+ onDoubleClick={logHandler('onDoubleClick')}
/>
)}