diff --git a/src/common/ResponsiveTable.tsx b/src/common/ResponsiveTable.tsx index f55098b..b69589e 100644 --- a/src/common/ResponsiveTable.tsx +++ b/src/common/ResponsiveTable.tsx @@ -546,15 +546,19 @@ export default function ResponsiveTable(props: Props) { const clampedWidth = Math.max(MIN_COLUMN_WIDTH, newWidthForIndex) const actualDelta = newWidths[index] - clampedWidth newWidths[index] = clampedWidth - newWidths.every((width, j) => { - if (j <= index || width === 0) return true - else if (newWidths[j] !== undefined) { - newWidths[j] = newWidths[j] + actualDelta - return false - } - }) + + if (actualDelta > 0) { + // Shrinking current column – give space to next column + newWidths[index + 1] = (newWidths[index + 1] ?? 0) + actualDelta + } else if (actualDelta < 0) { + // Growing current column – take from next column only what it can give + const nextWidth = newWidths[index + 1] ?? 0 + const availableFromNext = Math.max(0, nextWidth - MIN_COLUMN_WIDTH) + const takeFromNext = Math.min(-actualDelta, availableFromNext) + newWidths[index + 1] = nextWidth - takeFromNext + // If we couldn't take enough, the table grows (clampedWidth already applied) + } setRowWidths(newWidths) - } const MIN_COLUMN_WIDTH = 24;