Skip to content

Commit ed5c346

Browse files
gimmyhehekagol
authored andcommitted
fix(grid): [grid] fix footer bug in visual scroll scene (#2839)
* fix: [grid] fix footer bug in visual scroll scene * test: fix e2e test case
1 parent 62d3fd8 commit ed5c346

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

packages/vue/src/grid/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@opentiny/vue-grid",
33
"type": "module",
4-
"version": "3.21.1",
4+
"version": "3.21.2",
55
"description": "",
66
"license": "MIT",
77
"sideEffects": false,

packages/vue/src/grid/src/body/src/body.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -752,11 +752,12 @@ function renderDefEmpty(h) {
752752
}
753753

754754
const syncHeaderAndFooterScroll = ({ bodyElem, footerElem, headerElem, isX }) => {
755+
const scrollLeft = bodyElem.scrollLeft
755756
if (isX && headerElem) {
756-
headerElem.scrollLeft = bodyElem.scrollLeft
757+
headerElem.scrollLeft = scrollLeft
757758
}
758759
if (isX && footerElem) {
759-
footerElem.scrollLeft = bodyElem.scrollLeft
760+
footerElem.scrollLeft = scrollLeft
760761
}
761762
}
762763

@@ -871,10 +872,6 @@ export default defineComponent({
871872
// 空数据元素
872873
elemStore[`${keyPrefix}emptyBlock`] = $refs.emptyBlock
873874

874-
// 表体第一层div监听滚动事件
875-
$el.onscroll = this.scrollEvent
876-
$el._onscroll = this.scrollEvent
877-
878875
if (dropConfig) {
879876
const { plugin, row = true } = dropConfig
880877
plugin && row && (this.rowSortable = $table.rowDrop(this.$el))
@@ -908,7 +905,10 @@ export default defineComponent({
908905
'div',
909906
{
910907
ref: 'body',
911-
class: ['tiny-grid__body-wrapper', 'body__wrapper', { [classMap.isScrollload]: scrollLoad }]
908+
class: ['tiny-grid__body-wrapper', 'body__wrapper', { [classMap.isScrollload]: scrollLoad }],
909+
on: {
910+
scroll: this.scrollEvent
911+
}
912912
},
913913
[
914914
// 表格主体内容x轴方向虚拟滚动条占位元素

packages/vue/src/grid/src/table/src/methods.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,8 +1645,10 @@ const Methods = {
16451645
// 设置新的渲染列触发Vue渲染
16461646
this.tableColumn = ret.tableColumn
16471647
this.visibleColumnChanged = ret.visibleColumnChanged
1648-
1649-
this.$nextTick(this.updateStyle)
1648+
this.$nextTick(() => {
1649+
this.updateFooter()
1650+
this.updateStyle()
1651+
})
16501652
})
16511653
},
16521654
// 更新横向 X 可视渲染上下剩余空间大小

packages/vue/src/grid/src/table/src/utils/updateStyle.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function getTableWidth({ scrollXLoad, tWidth, tableColumn }) {
4444
}
4545

4646
function layoutFooter({
47+
elemStore,
4748
customHeight,
4849
footerHeight,
4950
headerHeight,
@@ -61,6 +62,11 @@ function layoutFooter({
6162
let tWidth = tableWidth
6263
// 如果是固定列与设置了超出隐藏
6364
let ret = getTableWidth({ scrollXLoad, tWidth, tableColumn })
65+
// 为表尾设置虚拟滚动占位宽度
66+
const spaceElem = elemStore['main-footer-x-space']
67+
if (spaceElem) {
68+
spaceElem.style.width = `${tableWidth}px`
69+
}
6470

6571
tableColumn = ret.tableColumn
6672
tWidth = ret.tWidth
@@ -242,6 +248,7 @@ export function handleLayout(params) {
242248
tableColumn = ret.tableColumn
243249
} else if (layout === 'footer') {
244250
tableColumn = layoutFooter({
251+
elemStore,
245252
customHeight,
246253
fixedWrapperElem,
247254
footerHeight,

0 commit comments

Comments
 (0)