Component not firing events in some render hooks

I have the following render hook set up in the boot method in: app/Providers/Filament/AdminPanelProvider.php
FilamentView::registerRenderHook(
    'panels::global-search.before',
    fn (): string => Blade::render('@livewire(\'publish-staff-button\')'),
);

This renders a simple component in: resources/views/livewire/publish-staff-button.blade.php
<x-filament::button wire:click="$dispatch('publish-staff')">
    Publish
</x-filament::button>

With the following method in the component class: app/Livewire/PublishStaffButton.php
#[On('publish-staff')]
public function publishStaff(): void
{
    // Do something...
}

Now if the render hook is in 'panels::global-search.start' then it will work but messes up the global search results (no idea why) but if it is in 'global-search.before' no events are fired.

Any ideas?
Solution
ok, so I have managed to get it working by just wrapping the button in a div, it seems as though it doesn't work when it is the root element!?
<div>
    <x-filament::button wire:click="publishStaff">
        {{$label}}
    </x-filament::button>
</div>
Was this page helpful?