Action is not called when first clicked on modal with modalContent()

Hi, I have a weird bug where I need to press twice on an action. The first time it does send a request to the server but it is not executing the action. Then every other click on whatever action does instantly open the action. It seems like the action is not loaded/mounted or something. I have attached a video to explain the problem visually. The modal opened is an action with a modalContent() where the content is a livewire component with a table. Any help would be appriciated!
6 Replies
Dennis Koch
Dennis Koch3mo ago
It does work normally outside the modal, right? Don't have a solution but it feels like it's the Livewire component that you nested in that first modal
gladjanus43
gladjanus433mo ago
yes it does indeed work normally! And also correct it is a livewire component nested. Do you think the issue lays there? And if so can I directly render the livewire component inside the modal?
Dennis Koch
Dennis Koch3mo ago
Do you think the issue lays there?
Would be my guess.
And if so can I directly render the livewire component inside the modal?
That's what you are doing right? I mean yes via "modalContent" but it's still directly inside the modal
gladjanus43
gladjanus433mo ago
this is the action which I mount when the planning is clicked
protected function showUsersAction(): Action
{
return Action::make('showUsers')
->modalHeading(false)
->modalContent(function ($arguments) {
$shift = Shift::find($arguments['shiftId']);
return view('uxit.deet.weekview.show-users', ['shift' => $shift]);
});
}
protected function showUsersAction(): Action
{
return Action::make('showUsers')
->modalHeading(false)
->modalContent(function ($arguments) {
$shift = Shift::find($arguments['shiftId']);
return view('uxit.deet.weekview.show-users', ['shift' => $shift]);
});
}
And then the view uxit.deet.weekview.show-users which is rendered does directly add the livewire table component
<div>
{{-- <x-show-user-component :$shift /> --}}
<div class="mb-5">
Shift at {{ $shift->company->name }}
</div>
<livewire:list-shift-users :$shift />
</div>
<div>
{{-- <x-show-user-component :$shift /> --}}
<div class="mb-5">
Shift at {{ $shift->company->name }}
</div>
<livewire:list-shift-users :$shift />
</div>
weird thing is, when I add the mountUsing method to one of the actions inside the custom livewire table it does instanlty execute the method.
Action::make('invite')
->action(fn() => ShiftService::inviteUsersForShift($this->shift))
->mountUsing(function () {
dd('test');
})
->requiresConfirmation()
Action::make('invite')
->action(fn() => ShiftService::inviteUsersForShift($this->shift))
->mountUsing(function () {
dd('test');
})
->requiresConfirmation()
weird thing is, when I add the mountUsing method to one of the actions inside the custom livewire table it does instanlty execute the method. this is the header action of the invite button. It does dd the value the first time clicked so I would assume it is mounted, it is just not executed
Action::make('invite')
->action(fn() => ShiftService::inviteUsersForShift($this->shift))
->mountUsing(function () {
dd('test');
})
->requiresConfirmation()
Action::make('invite')
->action(fn() => ShiftService::inviteUsersForShift($this->shift))
->mountUsing(function () {
dd('test');
})
->requiresConfirmation()
Dennis Koch
Dennis Koch3mo ago
So might be the requiresConfirmation()?
gladjanus43
gladjanus433mo ago
thought so to, but if I disable it, still needs 2 clicks tried looking into the livewire returned object but could not really get any wiser 🥲 Some other ideas that someone has? Really stuck on this one… Apperantly it does have to do with the requiresConfirmation... Dont know what I did last time. But I would like to have the user confirm their action. Any ideas why it is not mounting the modal of the confirmation?
Want results from more Discord servers?
Add your server