Skip to content

Commit

Permalink
fix(grid): [grid] fix style error when dynamic group header is set fi…
Browse files Browse the repository at this point in the history
…xed (#2789)
  • Loading branch information
gimmyhehe authored Jan 13, 2025
1 parent 87d859f commit 988e5e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/vue/src/grid/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@opentiny/vue-grid",
"type": "module",
"version": "3.21.0",
"version": "3.21.1",
"description": "",
"license": "MIT",
"sideEffects": false,
Expand Down
13 changes: 8 additions & 5 deletions packages/vue/src/grid/src/table/src/utils/autoCellWidth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ const setLeftOrRightPosition = ({ columnList, direction, headerEl, bodyEl, scrol
const ths = headerEl?.querySelectorAll(`[data-colid=${column.id}]`) || []
const tds = bodyEl.querySelectorAll(`[data-colid=${column.id}]`)
const allFixed = [...Array.from(ths), ...Array.from(tds)]

allFixed.forEach((td) => {
// 有纵向滚动条时,表头右冻结列需要补偿right定位
let compensatingWidth = 0
Expand All @@ -161,7 +160,7 @@ const setLeftOrRightPosition = ({ columnList, direction, headerEl, bodyEl, scrol
const setGroupHeaderPosition = ({ columnChart, direction }) => {
// 这里需要浅拷贝一份,避免改变原始数据的顺序
const colChart = columnChart.slice()

const finishColumns = new Set()
// 如果是右测冻结则需要反转数组后再进行循环
if (direction === 'right') {
colChart.reverse()
Expand All @@ -177,11 +176,15 @@ const setGroupHeaderPosition = ({ columnChart, direction }) => {
const leafDirectionPos = leafColumn?.style?.[direction] ?? null

if (leafDirectionPos !== null) {
columns.forEach((column) => {
columns.forEach((column, index) => {
// 叶子节点则返回
if (index === columns.length - 1) {
return
}
column.style = column.style || {}
const pos = column.style[direction] ?? null
if (pos === null) {
if (!finishColumns.has(column.id)) {
column.style[direction] = leafDirectionPos
finishColumns.add(column.id)
}
})
}
Expand Down

0 comments on commit 988e5e2

Please sign in to comment.