Skip to content

Commit

Permalink
Fix to not resest page when props has page
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Van Dyke committed Jul 10, 2019
1 parent 6dcb9d3 commit 080e026
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/MUIDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import MuiTable from '@material-ui/core/Table';
import classnames from 'classnames';
import cloneDeep from 'lodash.clonedeep';
import find from 'lodash.find';
import isEqual from 'lodash.isequal';
import isUndefined from 'lodash.isundefined';
import merge from 'lodash.merge';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -202,7 +201,7 @@ class MUIDataTable extends React.Component {
this.setHeadResizeable(this.headCellRefs, this.tableRef);

// When we have a search, we must reset page to view it
if (this.props.options.searchText) this.setState({ page: 0 });
if (this.props.options.searchText && !this.props.options.page) this.setState({ page: 0 });
}

componentDidUpdate(prevProps) {
Expand All @@ -213,7 +212,7 @@ class MUIDataTable extends React.Component {
this.updateOptions(this.props);
}

if (this.props.options.searchText !== prevProps.options.searchText) {
if (this.props.options.searchText !== prevProps.options.searchText && !this.props.options.page) {
// When we have a search, we must reset page to view it
this.setState({ page: 0 });
}
Expand Down

0 comments on commit 080e026

Please sign in to comment.