File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
src/shared/components/GenericList Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -124,20 +124,22 @@ export const GenericList = ({
124124 const [ searchQuery , setSearchQuery ] = useState ( '' ) ;
125125
126126 useEffect ( ( ) => {
127- if ( pagination ) {
128- // move back when the last item from the last page is deleted
129- const pagesCount = Math . ceil ( entries . length / pagination . itemsPerPage ) ;
130- if ( currentPage > pagesCount && pagesCount > 0 ) {
131- setCurrentPage ( pagesCount ) ;
127+ if ( entries . length > 0 ) {
128+ if ( pagination ) {
129+ // move back when the last item from the last page is deleted
130+ const pagesCount = Math . ceil ( entries . length / pagination . itemsPerPage ) ;
131+ if ( currentPage > pagesCount && pagesCount > 0 ) {
132+ setCurrentPage ( pagesCount ) ;
133+ }
132134 }
135+ setFilteredEntries (
136+ filterEntries (
137+ sorting ( sort , entries ) ,
138+ searchQuery ,
139+ searchSettings ?. textSearchProperties ,
140+ ) ,
141+ ) ;
133142 }
134- setFilteredEntries (
135- filterEntries (
136- sorting ( sort , entries ) ,
137- searchQuery ,
138- searchSettings ?. textSearchProperties ,
139- ) ,
140- ) ;
141143 // eslint-disable-next-line react-hooks/exhaustive-deps
142144 } , [
143145 searchQuery ,
You can’t perform that action at this time.
0 commit comments