-
Notifications
You must be signed in to change notification settings - Fork 216
Description
Browser
Chrome
Package version
v3.0.0 (@amzn/awsui-components-console)
React version
v19.2.3
Description
When using resizableColumns on a <Table>, columns that are dynamically added to columnDefinitions (e.g. swapping visible columns based on a filter/toggle) do not respect their minWidth. They are instead assigned DEFAULT_COLUMN_WIDTH (120px).
The issue is in use-column-widths.tsx L171:
newColumnWidths.set(column.id, column.width || DEFAULT_COLUMN_WIDTH);This only checks column.width and ignores column.minWidth. A column defined with { minWidth: 250 } but no explicit width will get 120px when dynamically added.
The initial render handles this correctly in readWidths (L28-L41) by doing Math.max(width, minWidth), but the dynamic column path does not.
Expected behavior
Dynamically added columns should respect minWidth, consistent with the initial render behavior. The fix would be something like:
const minWidth = column.minWidth || column.width || DEFAULT_COLUMN_WIDTH;
newColumnWidths.set(column.id, Math.max(column.width || DEFAULT_COLUMN_WIDTH, minWidth));Workaround
Set an explicit width equal to minWidth on affected columns:
{
id: 'myColumn',
header: 'My Column',
width: 250, // workaround: must set width explicitly
minWidth: 250,
cell: (item) => item.value,
}Source code
newColumnWidths.set(column.id, column.width || DEFAULT_COLUMN_WIDTH);Reproduction
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
- I checked the current issues for duplicate problems