Skip to content

Commit 9e7f867

Browse files
gimmyhehekagol
authored andcommitted
fix(grid): [grid] fix style error when dynamic group header is set fixed (#2789)
1 parent 1092504 commit 9e7f867

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
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.0",
4+
"version": "3.21.1",
55
"description": "",
66
"license": "MIT",
77
"sideEffects": false,

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ const setLeftOrRightPosition = ({ columnList, direction, headerEl, bodyEl, scrol
139139
const ths = headerEl?.querySelectorAll(`[data-colid=${column.id}]`) || []
140140
const tds = bodyEl.querySelectorAll(`[data-colid=${column.id}]`)
141141
const allFixed = [...Array.from(ths), ...Array.from(tds)]
142-
143142
allFixed.forEach((td) => {
144143
// 有纵向滚动条时,表头右冻结列需要补偿right定位
145144
let compensatingWidth = 0
@@ -161,7 +160,7 @@ const setLeftOrRightPosition = ({ columnList, direction, headerEl, bodyEl, scrol
161160
const setGroupHeaderPosition = ({ columnChart, direction }) => {
162161
// 这里需要浅拷贝一份,避免改变原始数据的顺序
163162
const colChart = columnChart.slice()
164-
163+
const finishColumns = new Set()
165164
// 如果是右测冻结则需要反转数组后再进行循环
166165
if (direction === 'right') {
167166
colChart.reverse()
@@ -177,11 +176,15 @@ const setGroupHeaderPosition = ({ columnChart, direction }) => {
177176
const leafDirectionPos = leafColumn?.style?.[direction] ?? null
178177

179178
if (leafDirectionPos !== null) {
180-
columns.forEach((column) => {
179+
columns.forEach((column, index) => {
180+
// 叶子节点则返回
181+
if (index === columns.length - 1) {
182+
return
183+
}
181184
column.style = column.style || {}
182-
const pos = column.style[direction] ?? null
183-
if (pos === null) {
185+
if (!finishColumns.has(column.id)) {
184186
column.style[direction] = leafDirectionPos
187+
finishColumns.add(column.id)
185188
}
186189
})
187190
}

0 commit comments

Comments
 (0)