Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bulk action selection does not preserve search filter #625

Closed
Lupennat opened this issue Jan 25, 2022 · 2 comments
Closed

bulk action selection does not preserve search filter #625

Lupennat opened this issue Jan 25, 2022 · 2 comments

Comments

@Lupennat
Copy link

Lupennat commented Jan 25, 2022

how to replicate the bug:

  • no filter applied total records = 100
  • filter results through search query, total records = 50
  • select checkbox in the table head
  • click select all (the number of selected elements respects the maximum number of filtered records 50)
  • execute a bulk action
  • the action is executed on all 100 records instead of 50 selected

possible solution:

    /**
     * @return Builder|Relation
     */
    public function selectedRowsQuery()
    {
        $query = $this->query();

        return $query->when($this->selectAll,
            fn ($query) => $this->applySearchFilter($query),
            fn ($query) => $query->whereIn($query->qualifyColumn($this->primaryKey), $this->selected)
        );
    }
@bureauvk
Copy link
Contributor

Can you show us your bulk method? Are you only applying changes to the selectedkeys?
I cant replicate this issue.

@Lupennat
Copy link
Author

Lupennat commented Jan 27, 2022

you can check it directly on the demo page https://tables.laravel-boilerplate.com/tailwind.
Type something in the search input that reduces the number of users but has more than one page (like "er"), then click the checkbox next to "sort" and then "select all" on the bar.
You will see X items selected, apply the "deactivate" bulk action, remove the search filter and you will see that all users are disabled instead of X.

@Lupennat Lupennat mentioned this issue Feb 2, 2022
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants