My search input is used to filter an array of users displayed in a table. The table has pagination set up so that only 10 users are shown per page. Oddly enough, the search filter only seems to work on the first page. Once I navigate to another page, the filtering stops working. This issue seems to be related to the use of .slice in my code. If I remove the .slice code, the search filter works fine. Can anyone shed some light on why this is happening? It feels like I'm missing something..
tableData() {
return this.users
.filter(
(user) =>
user.firstName.toLowerCase().includes(this.search.toLowerCase()) ||
user.lastName.toLowerCase().includes(this.search.toLowerCase()) ||
user.email.toLowerCase().includes(this.search.toLowerCase()),
)
.slice(this.perPage * (this.currentPage - 1), this.perPage * this.currentPage);
},