Cannot mutate reactive prop InteractsWithPageFilters Trait

I'm getting an error on my dashboard widget: cannot mutate reactive prop [filters] in component. I'm using the ApexChartWidget plugin, but I don't believe it's related to that. It seems to be related to the #[Reactive] prop on the InteractsWithPageFilters trait. I have another component that has a filters form and I'm dispatching an event when a user changes the filter. That seems to work fine, but when I switch tenants, if the user had a filter other than "all" then it's stored in the session when they navigate to the new dashboard. In the mount method I'm checking the tenant for the user and setting to "all" if not present. The error occurs just after that happens. I don't understand why I'm not able to update the prop in the mount method?
class MonthEndProgress extends ApexChartWidget
{
use InteractsWithPageFilters;

protected static ?string $chartId = 'monthEndProgress';

protected static ?string $heading = 'Month End Progress';

protected int | string | array $columnStart = 1;

protected int | string | array $columnSpan = 'full';

protected static ?int $sort = 2;

protected static ?string $pollingInterval = null;

public ?array $data = [];

/**
* Initializes the options for the object.
*/
public function mount(): void
{
$this->filters['location_filter'] = Session::get('dashboardSelectedUser') ?? 'all';

$tenant = Filament::getTenant();

if (!$tenant->members()->where('team_user.id', $this->filters['location_filter'])->first()) {
Log::debug('tenant has no member!');
Session::put('dashboardSelectedUser', 'all');
$this->filters['location_filter'] = 'all';
}

$this->options = $this->getOptions();

$this->form->fill();
Log::debug($tenant->members);
Log::debug($this->filters);

if (!$this->getDeferLoading()) {
$this->readyToLoad = true;
}
}
class MonthEndProgress extends ApexChartWidget
{
use InteractsWithPageFilters;

protected static ?string $chartId = 'monthEndProgress';

protected static ?string $heading = 'Month End Progress';

protected int | string | array $columnStart = 1;

protected int | string | array $columnSpan = 'full';

protected static ?int $sort = 2;

protected static ?string $pollingInterval = null;

public ?array $data = [];

/**
* Initializes the options for the object.
*/
public function mount(): void
{
$this->filters['location_filter'] = Session::get('dashboardSelectedUser') ?? 'all';

$tenant = Filament::getTenant();

if (!$tenant->members()->where('team_user.id', $this->filters['location_filter'])->first()) {
Log::debug('tenant has no member!');
Session::put('dashboardSelectedUser', 'all');
$this->filters['location_filter'] = 'all';
}

$this->options = $this->getOptions();

$this->form->fill();
Log::debug($tenant->members);
Log::debug($this->filters);

if (!$this->getDeferLoading()) {
$this->readyToLoad = true;
}
}
0 Replies
No replies yetBe the first to reply to this messageJoin