© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
4 replies
Ron

How to close an ActionGroup dropdown with a custom function after the function completes

I see from a similar post how to close the drop down immediately on click, but is there a way to close the drop down within the custom function itself to preserve the progress spinner on the action?

The code below shows an action w/in a group where the drop down is closed immediately (this code was from a similar post)
ActionGroup::make([
  Action::make('process')
                   ->action(function (Action $action) {
                        // ... run process function
                        // Is it possible to use the injected Action to close here, after processing
                    })
                    // Adding Extra Attributes will close the drop down immediately
                    ->extraAttributes(['x-on:click' => 'close']),
])->button();
ActionGroup::make([
  Action::make('process')
                   ->action(function (Action $action) {
                        // ... run process function
                        // Is it possible to use the injected Action to close here, after processing
                    })
                    // Adding Extra Attributes will close the drop down immediately
                    ->extraAttributes(['x-on:click' => 'close']),
])->button();
Solution
Its a bit similar:

Here is an example code:

      ActionGroup::make([
        Action::make('test')
          ->action(fn() => $v = "do something")
          ->after(fn($livewire)=> 
              $livewire->dispatch('close-menu')),
        ])->extraAttributes([
              "x-on:close-menu.window" => <<<JS
                        close();
                    JS
        ])
      ActionGroup::make([
        Action::make('test')
          ->action(fn() => $v = "do something")
          ->after(fn($livewire)=> 
              $livewire->dispatch('close-menu')),
        ])->extraAttributes([
              "x-on:close-menu.window" => <<<JS
                        close();
                    JS
        ])
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

How to close an ActionGroup dropdown with a custom action function
FilamentFFilament / ❓┊help
3y ago
Close dropdown after action completes
FilamentFFilament / ❓┊help
3y ago
Infolist ActionGroup Dropdown
FilamentFFilament / ❓┊help
3y ago
Multi Select / Dropdown - Close after select one
FilamentFFilament / ❓┊help
2y ago