Skip to content

Commit

Permalink
fix(react-grid): allow to change "TableTreeColumn.for" property in ru…
Browse files Browse the repository at this point in the history
…ntime (#2650)
  • Loading branch information
LazyLahtak authored Jan 28, 2020
1 parent 9fdbd67 commit bda719e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
46 changes: 46 additions & 0 deletions packages/dx-react-grid/src/plugins/table-tree-column.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,50 @@ describe('TableTreeColumn', () => {
value: defaultDeps.template.tableCell.tableRow.row.value,
});
});

it('should change "for" property in runtime', () => {
class Test extends React.Component {
constructor(props) {
super(props);
this.state = {
columnName: props.columnName,
};
}

render() {
const { columnName } = this.state;
isTreeTableCell.mockImplementation((_, tableColumn) => (
tableColumn.column.name === columnName
));

return(
<PluginHost>
{pluginDepsToComponents(defaultDeps)}
<TableTreeColumn
{...defaultProps}
for={columnName}
/>
</PluginHost>
);
}
}

const tree = mount((
<Test
columnName={'b'}
/>
));

expect(tree.find(defaultProps.cellComponent).exists())
.toBeFalsy();

tree.setState({
columnName: 'a',
});

expect(tree.find(defaultProps.cellComponent).exists())
.toBeTruthy();
expect(tree.find(defaultProps.cellComponent).props().column.name)
.toEqual('a');
});
});
1 change: 1 addition & 0 deletions packages/dx-react-grid/src/plugins/table-tree-column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class TableTreeColumnBase extends React.PureComponent<TableTreeColumnProps> {
{ name: 'Table' },
{ name: 'TableHeaderRow', optional: true },
]}
key={forColumnName}
>
<Getter name="tableTreeColumnName" value={forColumnName} />
<Template
Expand Down

0 comments on commit bda719e

Please sign in to comment.