Skip to content

Render tables with no columns correctly#737

Merged
bantic merged 3 commits intomasterfrom
bantic/735/fix
Jul 23, 2019
Merged

Render tables with no columns correctly#737
bantic merged 3 commits intomasterfrom
bantic/735/fix

Conversation

@bantic
Copy link
Copy Markdown
Contributor

@bantic bantic commented Jul 22, 2019

Fixes #735.

When a table has no columns, the root ColumnTreeNode's isLeaf property was mistakenly evaluated as true because it (the columnTreeNode) itself has no subcolumns. As a result, when ensureWidthConstraint is called and the ColumnTree iterates the columns to tally their width, the meta for the root node is incorrectly retrieved:

if (get(this, 'isLeaf')) {
let column = get(this, 'column');
let columnWidth = get(column, 'width');
if (typeof columnWidth === 'number') {
return columnWidth;
} else {
let meta = get(this, 'tree.columnMetaCache').get(column);
return get(meta, '_width');
}
}

There is no meta for the root ColumnTreeNode, though, so the attempt to get(meta, '_width') throws: Assertion Failed: Cannot call get with '_width' on an undefined object.

The root column tree node should not ever be treated as a leaf, so this PR ensures that it won't be.

@bantic bantic mentioned this pull request Jul 22, 2019
Add failing test for #735
@bantic bantic changed the title Potential fix for #735 Render tables with no columns correctly Jul 22, 2019
@bantic bantic added this to the Prepare for 2.0 release milestone Jul 22, 2019
@bantic bantic requested review from cyril-sf and mixonic July 22, 2019 22:08
@bantic bantic merged commit 111acb0 into master Jul 23, 2019
@bantic bantic deleted the bantic/735/fix branch July 23, 2019 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Rendering a table without columns -> Assertion Failed: Cannot call get with '_width' on an undefined object

2 participants