Skip to content

Commit b5855ee

Browse files
authored
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 2bf2a78 commit b5855ee

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

examples/sites/demos/pc/app/grid/editor/custom-edit.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { test, expect } from '@playwright/test'
33
test('多行编辑', async ({ page }) => {
44
page.on('pageerror', (exception) => expect(exception).toBeNull())
55
await page.goto('grid-editor#editor-custom-edit')
6-
await expect(page.getByRole('row', { name: '1 请选择 保存 取消' }).getByRole('textbox').first()).toBeVisible()
7-
await expect(page.getByRole('row', { name: '2 请选择 保存 取消' }).getByRole('textbox').first()).toBeVisible()
6+
await expect(page.getByRole('cell', { name: 'GFD 科技有限公司' }).getByRole('textbox')).toBeVisible()
7+
await expect(page.getByRole('cell', { name: 'WWWW 科技有限公司' }).getByRole('textbox')).toBeVisible()
88
})

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
@@ -751,11 +751,12 @@ function renderDefEmpty(h) {
751751
}
752752

753753
const syncHeaderAndFooterScroll = ({ bodyElem, footerElem, headerElem, isX }) => {
754+
const scrollLeft = bodyElem.scrollLeft
754755
if (isX && headerElem) {
755-
headerElem.scrollLeft = bodyElem.scrollLeft
756+
headerElem.scrollLeft = scrollLeft
756757
}
757758
if (isX && footerElem) {
758-
footerElem.scrollLeft = bodyElem.scrollLeft
759+
footerElem.scrollLeft = scrollLeft
759760
}
760761
}
761762

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

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

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,8 +1644,10 @@ const Methods = {
16441644
// 设置新的渲染列触发Vue渲染
16451645
this.tableColumn = ret.tableColumn
16461646
this.visibleColumnChanged = ret.visibleColumnChanged
1647-
1648-
this.$nextTick(this.updateStyle)
1647+
this.$nextTick(() => {
1648+
this.updateFooter()
1649+
this.updateStyle()
1650+
})
16491651
})
16501652
},
16511653
// 更新横向 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)