material-table icon indicating copy to clipboard operation
material-table copied to clipboard

SearchText reset when parent component renders

Open re-anderson opened this issue 7 years ago • 1 comments

Describe the bug The search box gets cleared if the parent component of a table gets rendered. For example, when a useState hook is triggered.

To Reproduce Steps to reproduce the behavior:

  1. Create a component with a useState hook and MaterialTable as a child
  2. Type in a search term in the table's search box
  3. Trigger the hook
  4. See that search text gets cleared, along with resetting table results

Expected behavior The search text is persisted on renders of parent component

Screenshots search-cleared

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • Version 78.0.3904.70

Additional context This seems to be related to pull request #1225. I tested by changing line 64 of material-table.js to props.options.searchText && this.dataManager.changeSearchText(props.options.searchText); and the search text was persisted.

edit: specify useState hook

re-anderson avatar Oct 31 '19 14:10 re-anderson

Closing since this should've been fixed with PR #1298

re-anderson avatar Nov 08 '19 14:11 re-anderson