Skip to content

Commit 796f37d

Browse files
committed
fix: 修复测试用例
1 parent 4a942e9 commit 796f37d

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

packages/s2-core/__tests__/unit/interaction/selected-cell-move-spec.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,26 @@ describe('Interaction Keyboard Move Tests', () => {
3838
s2.facet = {
3939
layoutResult: {
4040
colLeafNodes: [
41-
{ x: 0, id: '0' },
42-
{ x: 1, id: '1' },
41+
{ x: 0, id: '0', colIndex: 0 },
42+
{ x: 1, id: '1', colIndex: 1 },
4343
],
4444
},
45-
viewCellHeights: { getCellOffsetY: (index) => 0 },
4645
getTotalHeightForRange: (start, end) => 0,
4746
scrollWithAnimation: (data) => {},
47+
getScrollOffset: () => ({ scrollX: 0, scrollY: 0 }),
48+
panelBBox: {
49+
viewportHeight: 200,
50+
viewportWidth: 200,
51+
},
52+
viewCellWidths: [],
53+
viewCellHeights: {
54+
getCellOffsetY: (index) => 0,
55+
getIndexRange: () => [0, 3],
56+
},
57+
getRealScrollX: () => 0,
58+
cornerBBox: {
59+
width: 80,
60+
},
4861
} as any;
4962
s2.interaction.intercepts.clear();
5063
s2.interaction.isEqualStateName = () => false;

packages/s2-core/src/interaction/selected-cell-move.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,18 @@ export class SelectedCellMove extends BaseEvent implements BaseEventImplement {
8888
const { colLeafNodes } = facet.layoutResult;
8989
const { scrollX, scrollY } = facet.getScrollOffset();
9090
const { viewportHeight: height, viewportWidth: width } = facet.panelBBox;
91-
const frozenColWidth = Math.floor(frozenColGroup.getBBox().width);
92-
const frozenTrailingColWidth = Math.floor(
93-
frozenTrailingColGroup.getBBox().width,
94-
);
95-
const frozenRowHeight = Math.floor(frozenRowGroup.getBBox().height);
96-
const frozenTrailingRowHeight = Math.floor(
97-
frozenTrailingRowGroup.getBBox().height,
98-
);
91+
const frozenColWidth = frozenColGroup
92+
? Math.floor(frozenColGroup.getBBox().width)
93+
: 0;
94+
const frozenTrailingColWidth = frozenTrailingColGroup
95+
? Math.floor(frozenTrailingColGroup.getBBox().width)
96+
: 0;
97+
const frozenRowHeight = frozenRowGroup
98+
? Math.floor(frozenRowGroup.getBBox().height)
99+
: 0;
100+
const frozenTrailingRowHeight = frozenTrailingRowGroup
101+
? Math.floor(frozenTrailingRowGroup.getBBox().height)
102+
: 0;
99103

100104
const indexes = calculateInViewIndexes(
101105
scrollX,

0 commit comments

Comments
 (0)