Skip to content

Bulk actions execute on non-selectable records when using 'Select all matching' #20050

@hamdyelbatal122

Description

@hamdyelbatal122

Description

When configuring custom selectability on a table using checkIfRecordIsSelectableUsing(), the checkboxes for non-selectable records are correctly disabled in the UI.

However, if a user selects all records on the page and then clicks the banner link to "Select all matching records" (which switches Livewire to track deselected records), the bulk action ends up executing on the non-selectable records as well.

This happens because the backend database query has no awareness of the PHP closure defined in checkIfRecordIsSelectableUsing().

To prevent this, Filament currently disables deselection tracking entirely when custom selectability is active (canTrackDeselectedRecords() returns false), forcing the client to download all individual IDs. But this workaround causes severe performance issues/memory limits on large datasets, and doesn't actually prevent the backend from resolving non-selectable records if deselection tracking is somehow active or simulated.


Reproduction Repository

https://github.com/hamdyelbatal122/filament-reproduction-20050

Steps to Reproduce

  1. Clone the reproduction repository and install dependencies:

    composer install
  2. Setup database, migrations, and seed the demo data:

    composer setup
  3. Start the server:

    php artisan serve
  4. Log in at http://127.0.0.1:8000/login with:

    • Email: admin@filamentphp.com
    • Password: password
  5. Navigate to the posts page: http://127.0.0.1:8000/blog/posts

  6. Notice that the checkbox for "Draft" posts is disabled (configured using checkIfRecordIsSelectableUsing in PostsTable.php).

  7. Check the master checkbox in the header to select all posts on the page, then click the banner link "Select all 83 posts matching...".

  8. Click the bulk actions dropdown and trigger the "Test Select All" action.

  9. You will see an notification saying:

    Executed on 101 records. Drafts included: 18

    (This shows that the bulk action executed on all records, including the 18 draft posts that are non-selectable).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions