ingeday
ingeday
FFilament
Created by ingeday on 10/8/2024 in #❓┊help
widget doesn't update properly from another property received with $listeners
Hello friends!! I have two components: WidgetA where I set a filter
public string $filter = 'weekly';
public string $filter = 'weekly';
and I use setFilter to fire an event filterUpdated
public function setFilter(string $filter): void
{
$this->filter = $filter;
$this->dispatch('filterUpdated', $this->filter); // Emitir el evento con el nuevo filtro
}
public function setFilter(string $filter): void
{
$this->filter = $filter;
$this->dispatch('filterUpdated', $this->filter); // Emitir el evento con el nuevo filtro
}
Then, in the WidgetB I have this
public string $filter = 'weekly';
protected $listeners = ['filterUpdated' => 'setFilter'];

public function setFilter(string $filter): void
{
$this->filter = $filter;

}

public function table(Table $table): Table
{
....
}
public string $filter = 'weekly';
protected $listeners = ['filterUpdated' => 'setFilter'];

public function setFilter(string $filter): void
{
$this->filter = $filter;

}

public function table(Table $table): Table
{
....
}
When filter is updated in WidgetA I get the value but looks like widget renders before getting the new value for filter, because when I update again the render take the previous value.
Could you help with any ideas? Thanks,
2 replies