Skip to content

InteractsWithPageTable widget shows stale data when switching tabs (requires two clicks to update) #19280

@andreia

Description

@andreia

Package

filament/filament

Package Version

v5.2.1

Laravel Version

v12.51.0

Livewire Version

v4.1.4

PHP Version

v4.4.14

Problem description

When using a StatsOverviewWidget with the InteractsWithPageTable trait on a ListRecords page that has tabs (via getTabs()), switching tabs updates the table correctly but the widget displays stale data from the previous tab. The user must click the same tab a second time for the stats to reflect the correct filtered data.
This appears to be a reactivity issue with how the #[Reactive] $activeTab property (defined in InteractsWithPageTable) is synchronized between the page and the widget. The page updates activeTab and re-renders, but the widget doesn't re-render with the new prop value in the same request cycle — it lags behind by one interaction.

Expected behavior

When switching tabs, the stats widget should immediately reflect the data for the newly active tab in the same request, without requiring a second click.

Steps to reproduce

This issue is reproducible on the official Filament demo at the Orders resource (/admin/shop/orders), which uses the same InteractsWithPageTable + ExposesTableToWidgets pattern with tabs:
OrderStats widget
ListOrders page

Steps:

  • Visit a ListRecords page that has tabs and a header widget using InteractsWithPageTable
  • Note the stats displayed (they match the current tab)
  • Click a different tab
  • Observe: the table updates to the new tab, but the stats still show values from the previous tab
  • Click the same tab again (or any other tab)
  • Observe: the stats now update — but they show data for the tab you clicked in step 3, not the current one
  • The widget is always "one click behind."

Investigation

The InteractsWithPageTable trait declares $activeTab as #[Reactive], and ExposesTableToWidgets::getWidgetData() passes activeTab from the page to the widget. The page correctly updates activeTab in updatedActiveTab() (from HasTabs), but the child widget component doesn't re-render with the new prop value in the same Livewire response.

Workaround: Dispatching a Livewire event from the page and listening for it in the widget forces a proper re-render:

// In the ListRecords page:
public function updatedActiveTab(): void
{
    parent::updatedActiveTab();

    $this->dispatch('filterUpdated');
}
// In the widget:
use Livewire\Attributes\On;

#[On('filterUpdated')]
public function refresh(): void {}

Reproduction repository (issue will be closed if this is not valid)

https://github.com/filamentphp/demo/tree/5.x/app/Filament/Resources/Shop/Orders

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions