Skip to content

Commit

Permalink
Page reset762 (#763)
Browse files Browse the repository at this point in the history
* Fix to not resest page when props has page

#762
gregnb/mui-datatables#762

* Switching to serverSide instead of page to keep client side working the same way
  • Loading branch information
SkyCaptainess committed Aug 9, 2019
1 parent e73103f commit 335349b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/MUIDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ class MUIDataTable extends React.Component {
componentDidMount() {
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 });
// When we have a search, we must reset page to view it unless on serverSide since paging is handled by the user.
if (this.props.options.searchText && !this.props.options.serverSide) this.setState({ page: 0 });
}

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

if (this.props.options.searchText !== prevProps.options.searchText) {
// When we have a search, we must reset page to view it
if (this.props.options.searchText !== prevProps.options.searchText && !this.props.options.serverSide) {
// When we have a search, we must reset page to view it unless on serverSide since paging is handled by the user.
this.setState({ page: 0 });
}

Expand Down

0 comments on commit 335349b

Please sign in to comment.