Action Keybinds Failing After Use

I created a custom page that runs the following
public function approveAction(): Action
{
return Action::make('Approve')
->keyBindings(['a'])
->color('success')
->action(function(){
$this->media->setCustomProperty('approved', true);
$this->media->save();
Notification::make()
->title('Media has been approved.')
->success()
->send();
$this->getNextMedia();
});
}
private function getNextMedia()
{
$this->index++;
if($this->index >= $this->mediaCollection->count()){
Notification::make()
->title('No non-approved media found.')
->success()
->send();
return redirect()->route('filament.admin.resources.users.index');
}

$this->media = $this->mediaCollection->get($this->index);

$this->url = $this->media->getUrl();
}
public function approveAction(): Action
{
return Action::make('Approve')
->keyBindings(['a'])
->color('success')
->action(function(){
$this->media->setCustomProperty('approved', true);
$this->media->save();
Notification::make()
->title('Media has been approved.')
->success()
->send();
$this->getNextMedia();
});
}
private function getNextMedia()
{
$this->index++;
if($this->index >= $this->mediaCollection->count()){
Notification::make()
->title('No non-approved media found.')
->success()
->send();
return redirect()->route('filament.admin.resources.users.index');
}

$this->media = $this->mediaCollection->get($this->index);

$this->url = $this->media->getUrl();
}
And it IS working however after it loads the next media its almost like the key bind is not bound anymore. I have to hard refresh the page to get the key binds to react. Any ideas on how to persist it?
1 Reply
datarecall
datarecallOP8mo ago
I just tested it without the getNextMedia to see if it allowed pressing it more then once, it seems that I can only press the keybind once and then it stops working, is there a debounce or something I can override ?
Want results from more Discord servers?
Add your server