Skip to content

Commit

Permalink
fix: 取消双击表格时默认选中文本的默认浏览器行为 close #2798
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinke666 committed Jul 1, 2024
1 parent 73b9b6c commit 6fb9b2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/s2-core/src/sheet-type/spread-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/s2-react/playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1586,6 +1586,7 @@ function MainLayout() {
onDataCellContextMenu={logHandler(
'onDataCellContextMenu',
)}
onDoubleClick={logHandler('onDoubleClick')}
/>
</React.StrictMode>
)}
Expand Down

0 comments on commit 6fb9b2f

Please sign in to comment.