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: 取消双击表格时浏览器默认的选中文本行为 close #2798 #2800

Merged
merged 2 commits into from
Jul 5, 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ exports[`<SheetComponent/> Tests Render Tests should render editable sheet by sn
>
<canvas
height="400"
style="width: 200px; height: 200px; touch-action: none; display: block;"
style="width: 200px; height: 200px; touch-action: none; display: block; user-select: none;"
width="400"
/>
</div>
Expand Down Expand Up @@ -364,7 +364,7 @@ exports[`<SheetComponent/> Tests Render Tests should render gridAnalysis sheet b
>
<canvas
height="400"
style="width: 200px; height: 200px; touch-action: none; display: block;"
style="width: 200px; height: 200px; touch-action: none; display: block; user-select: none;"
width="400"
/>
</div>
Expand Down Expand Up @@ -622,7 +622,7 @@ exports[`<SheetComponent/> Tests Render Tests should render pivot sheet by snaps
>
<canvas
height="400"
style="width: 200px; height: 200px; touch-action: none; display: block;"
style="width: 200px; height: 200px; touch-action: none; display: block; user-select: none;"
width="400"
/>
</div>
Expand Down Expand Up @@ -880,7 +880,7 @@ exports[`<SheetComponent/> Tests Render Tests should render strategy sheet by sn
>
<canvas
height="400"
style="width: 200px; height: 200px; touch-action: none; display: block;"
style="width: 200px; height: 200px; touch-action: none; display: block; user-select: none;"
width="400"
/>
</div>
Expand Down Expand Up @@ -1138,7 +1138,7 @@ exports[`<SheetComponent/> Tests Render Tests should render table sheet by snaps
>
<canvas
height="400"
style="width: 200px; height: 200px; touch-action: none; display: block;"
style="width: 200px; height: 200px; touch-action: none; display: block; user-select: none;"
width="400"
/>
</div>
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
Loading