Skip to content

Commit

Permalink
DataView: only reset page if search has actually changed
Browse files Browse the repository at this point in the history
  • Loading branch information
roo2 committed May 2, 2024
1 parent 3c91548 commit ad336ac
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/dataviews/src/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ const Search = memo( function Search( { label, view, onChangeView } ) {
onChangeViewRef.current = onChangeView;
}, [ onChangeView ] );
useEffect( () => {
onChangeViewRef.current( {
...view,
page: 1,
search: debouncedSearch,
} );
if ( debouncedSearch !== view.search ) {
onChangeViewRef.current( {
...view,
page: 1,
search: debouncedSearch,
} );
}
}, [ debouncedSearch ] );
const searchLabel = label || __( 'Search' );
return (
Expand Down

0 comments on commit ad336ac

Please sign in to comment.