Skip to content

Commit 42086a8

Browse files
sealdayclaude
andcommitted
fix(canvas): fill background to prevent gaps when scrolling to edges
- Fill entire canvas with grid background color before rendering - Update scrollbar CSS to use 8px instead of 15px - Prevents empty areas when content width is less than view width 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 76d9b99 commit 42086a8

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/sheet/src/sheet/hooks/useTableRender.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,17 @@ export function useTableRender(data: DataProxy | null) {
305305
const fh = rows.height;
306306

307307
// 调整 canvas 大小
308-
draw.resize(data.viewWidth(), data.viewHeight());
308+
const viewWidth = data.viewWidth();
309+
const viewHeight = data.viewHeight();
310+
draw.resize(viewWidth, viewHeight);
309311
draw.clear();
310312

313+
// 先填充整个背景(防止滚动到边缘时出现空白区域)
314+
draw.save();
315+
draw.attr({ fillStyle: RenderConfig.grid.backgroundColor });
316+
draw.fillRect(0, 0, viewWidth, viewHeight);
317+
draw.restore();
318+
311319
const viewRange = data.viewRange();
312320
const tx = data.freezeTotalWidth();
313321
const ty = data.freezeTotalHeight();

packages/sheet/src/sheet/sheet.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ body {
303303
opacity: 0.9;
304304
z-index: 12;
305305
&.horizontal {
306-
right: 15px;
306+
right: 8px;
307307
overflow-x: scroll;
308308
overflow-y: hidden;
309309
> div {
@@ -312,7 +312,7 @@ body {
312312
}
313313
}
314314
&.vertical {
315-
bottom: 15px;
315+
bottom: 8px;
316316
overflow-x: hidden;
317317
overflow-y: scroll;
318318
> div {

0 commit comments

Comments
 (0)