Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在循环中使用index来判断是否为叶子节点可能会导致错误,因为这假设了叶子节点总是最后一个元素。建议使用更可靠的方法来识别叶子节点,以避免潜在的逻辑错误。

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
Loading