react-component / react-component/table
Column width problem when parent is not wide enough in Chrome
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.4k
- Forks
- 618
- Avg merge
- 10h 19m
- Merged PRs (30d)
- 2
Description
When the column width is set in columns property but the parent is not wide enough, Chrome and Firefox tend to behave differently:
In Chrome:
Chrome adjusts the table width to fit its parent, and all columns' width are adjusted according to specified column width.

In Firefox:
Firefox lets the table overflow and doesn't try to adjust the width. All columns' width are kept as specified. IE has a similar behavior.

In the above example, the parent width is set to 500px and column widths are 300, 100 and 200, respectively, in columns object. Test environments are Chrome/Chromium 71, Firefox 64 and IE 11.
When I looked into the issue, I've found that rc-table specified both width and min-width style in <col>. But as pointed out in Google Chrome Help Forum[1], Chrome doesn't implement min-width style on <col> element because it is not in W3C's Recommendation[2].
One of the solution I come up with is that set width and min-width in <th> rather than <col>. But the drawback is rc-table supports a method that doesn't have any <th> elements (showHeader={false}), which makes this workaround not work.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the 500px-parent case with column widths of 300, 100, and 200 in Chrome, Firefox, and IE, including showHeader={false}. Inspect how rc-table applies width and min-width to col and th elements; done means the chosen behavior is consistent across the reported browsers without breaking tables that have no header.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100