Skip to content

[Bug]: resizableColumns: dynamically added columns ignore minWidth, fall back to DEFAULT_COLUMN_WIDTH #4236

@Miles123K

Description

@Miles123K

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

use-column-widths.tsx L171:

newColumnWidths.set(column.id, column.width || DEFAULT_COLUMN_WIDTH);

Reproduction

No response

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions