© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
11 replies
CGM

In a test, should fillForm() be firing afterStateUpdated()?

I have the following field:
ColorPicker::make('primary_color')
  ->live()
  ->afterStateUpdated(function ($state) {
    $this->dispatch('applyThemeColors', [
      'primary_color' => $state,
    ]);
  })
  ->hex()
  ->hexColor()
  ->nullable()
  ->helperText('Leave blank to use default colors'),
ColorPicker::make('primary_color')
  ->live()
  ->afterStateUpdated(function ($state) {
    $this->dispatch('applyThemeColors', [
      'primary_color' => $state,
    ]);
  })
  ->hex()
  ->hexColor()
  ->nullable()
  ->helperText('Leave blank to use default colors'),


and the following test:
    $component = livewire(BrandingSettings::class, ['location' => null])
    ->assertSuccessful()
    ->fillForm(['primary_color' => '#007bff'])
    ->assertDispatched('applyThemeColors');
    $component = livewire(BrandingSettings::class, ['location' => null])
    ->assertSuccessful()
    ->fillForm(['primary_color' => '#007bff'])
    ->assertDispatched('applyThemeColors');


On the live site it all works, I assumed this test would have picked it up, however it doesn't.

I'm just wondering is there something I need to do in my test to ensure the afterStateUpdated() is fired? The field is set to live().
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Select searchable() not firing afterStateUpdated()
FilamentFFilament / ❓┊help
3y ago
Using both afterStateUpdated AND afterStateUpdatedJs
FilamentFFilament / ❓┊help
8mo ago
afterStateUpdated not firing when removing from multiple FileUpload
FilamentFFilament / ❓┊help
17mo ago
Set the state of ->afterStateUpdated inside a test
FilamentFFilament / ❓┊help
3y ago