fix(table): align constrained widths and guard invalid fr factors

This commit is contained in:
maoyingjie
2026-10-29 11:11:10 +08:00
parent 86d76a0675
commit c019768e6a
6 changed files with 110 additions and 17 deletions
@@ -88,9 +88,8 @@ export default defineComponent({
const cssWidth = (value: string | number | undefined) => {
if (value === undefined) return undefined;
if (typeof value === "number") return `${value}px`;
// CSS Grid fr units are not valid table widths. Treat Nfr as a flexible
// column (native width:auto sharing remaining space). This does not
// implement RAC fr weight proportions across columns.
// fr is resolved by TableContent after measurement. Leave native layout
// untouched until a managed pixel width is available.
if (/^\d+(\.\d+)?fr$/.test(value)) return undefined;
return value;
};
@@ -118,7 +117,8 @@ export default defineComponent({
? `${resolvedWidth.value}px`
: cssWidth(width.value),
minWidth: cssWidth(
typeof width.value === "number"
resolvedWidth.value === undefined &&
typeof width.value === "number"
? Math.max(props.minWidth ?? 0, width.value)
: props.minWidth,
),