Skip to content

Commit

Permalink
fix: scroll.x max-content not working
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Oct 18, 2019
1 parent d2fc944 commit a7f4cbb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/BaseTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,7 @@ class BaseTable<ValueType> extends React.Component<BaseTableProps<ValueType>> {

if (!fixed && scroll.x) {
// not set width, then use content fixed width
if (scroll.x === true) {
tableStyle.tableLayout = 'fixed';
} else {
tableStyle.width = scroll.x;
}
tableStyle.width = scroll.x === true ? 'max-content' : scroll.x;
}

const Table = hasBody ? components.table : 'table';
Expand Down
9 changes: 7 additions & 2 deletions src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,19 @@ class Table<ValueType> extends React.Component<TableProps<ValueType>, TableState
if (typeof tableLayout !== 'undefined') {
return tableLayout === 'fixed';
}
// if one column is fixed or ellipsis, use fixed table layout to fix align issue
if (columns.some(({ fixed, ellipsis }) => !!fixed || !!ellipsis)) {
// if one column is ellipsis, use fixed table layout to fix align issue
if (columns.some(({ ellipsis }) => !!ellipsis)) {
return true;
}
// if header fixed, use fixed table layout to fix align issue
if (useFixedHeader || scroll.y) {
return true;
}
// if scroll.x is number/px/% width value, we should fixed table layout
// to avoid long word layout broken issue
if (scroll.x && scroll.x !== true && scroll.x !== 'max-content') {
return false;
}
return false;
}

Expand Down

0 comments on commit a7f4cbb

Please sign in to comment.