Filter Widget based on Active Tab Query

I have a List page with multiple tabs.
The List Page also has a Widget in header.

Is there a way I can have the widget filter based on the query of the active tab. So when a user switches tab, that tab's query is also applied to the widget, so we are running query only on the shown results
Solution
Found Solution:

protected function getHeaderWidgets(): array
    {
        $activeTabRecords = $this->modifyQueryWithActiveTab(CustomModel::query())->get();

        return [
            new MyCustomWidget::make(['records' => $activeTabRecords]),
        ];
    }

and then in MyCustomWidget have:
public $records
property defined
Was this page helpful?