Count selected records in Table Builder Bulk Action form

This is my code:

BulkAction::make('action')
  ->icon('heroicon-o-cog-6-tooth')
  ->deselectRecordsAfterCompletion()
  ->form(function (Collection $records) {
      return [
          Placeholder::make('Cost Breakdown')
              ->content('Selected: ' . number_format($records->count()))
      ];
  }),


This will count the total of selected records and show it in the placeholder. However, if I close the modal and select one more record, the count does not change. It seems that Filament caches the modal content in subsequent requests. How can I get the fresh count data every time the modal opens?
Was this page helpful?