Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/Issue 365 #896

Merged
merged 2 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/MUIDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class MUIDataTable extends React.Component {

componentDidUpdate(prevProps) {
if (this.props.data !== prevProps.data || this.props.columns !== prevProps.columns) {
this.updateOptions(this.props);
this.updateOptions(this.options, this.props);
this.setTableData(this.props, TABLE_LOAD.INITIAL, () => {
this.setTableAction('propsUpdate');
});
Expand All @@ -254,8 +254,8 @@ class MUIDataTable extends React.Component {
}
}

updateOptions(props) {
this.options = assignwith(this.options, props.options, (objValue, srcValue, key) => {
updateOptions(options, props) {
this.options = assignwith(options, props.options, (objValue, srcValue, key) => {
// Merge any default options that are objects, as they will be overwritten otherwise
if (key === 'textLabels' || key === 'downloadOptions') return merge(objValue, srcValue);
return;
Expand Down Expand Up @@ -325,9 +325,7 @@ class MUIDataTable extends React.Component {
mergeDefaultOptions(props) {
const defaultOptions = this.getDefaultOptions();

this.options = merge(defaultOptions, props.options);

this.handleOptionDeprecation(props);
this.updateOptions(defaultOptions, this.props);
}

validateOptions(options) {
Expand Down
10 changes: 10 additions & 0 deletions test/MUIDataTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,16 @@ describe('<MUIDataTable />', function() {
assert.deepEqual(state.rowsPerPageOptions, [5, 10, 15]);
});

it('should allow empty array rowsPerPageOptions when provided in options', () => {
const options = {
rowsPerPageOptions: [],
};

const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} options={options} />);
const state = shallowWrapper.dive().state();
assert.deepEqual(state.rowsPerPageOptions, []);
});

it('should render pagination when enabled in options', () => {
const options = {
pagination: true,
Expand Down