Power-Components / livewire-powergrid

⚡ PowerGrid generates modern, powerful and easy-to-customize data tables using Laravel Livewire.
https://livewire-powergrid.com
MIT License
1.46k stars 215 forks source link

"emitTo" action is being rendered as just "emit" #418

Closed agharium closed 2 years ago

agharium commented 2 years ago

Have you searched through other issues to see if your problem is already reported or has been fixed?

Did you read the documentation?

Have you tried to publish the views?

You can publish the views to make sure there is no "old code" trapped in views which are not up-to-date.

To publish, run: php artisan vendor:publish --tag=livewire-powergrid-views

Is there an error in the console?

Software Version

Software Version (exactly)
PowerGrid v2.4.7
Laravel v8.83.11
Livewire v2.10.5
Alpine JS v3.x.x

Theme


Describe the bug

What happened?

Trying to setup action with emitTo (open a bootstrap custom modal):

Button::add('edit')
    ->caption('Editar')
    ->tooltip('Editar')
    ->class('btn btn-warning round button-edit')
    ->emitTo('general-form-modal', 'toggle', ['model' => 'city', 'action' => 'edit'])
class GeneralFormModal extends Component
{
    public $listeners = [
        'toggle' => 'toggle',
    ];

    ...

    public function toggle($model, $action, $id = null)
    {
        $this->_model = $model;
        $this->_action = $action;
        $this->_id = $id;

        $this->dispatchBrowserEvent('toggleGeneralFormModal');
    }

    ... 

But the final render is..

image

As you can see, "emit" event instead of "emitTo" (the one I called for on the PHP).

Also, even with only "emit", it looks like the parameters aren't being treated correctly (even though the image shows that the rendered action has those parameters on it) when I click on the action button:

Illuminate\Contracts\Container\BindingResolutionException
Unable to resolve dependency [Parameter #1 [ <required> $action ]] in class App\Http\Livewire\GeneralFormModal

To Reproduce...

Simply create a action with "emitTo" and parameters.

Suggestions

No idea. I swear I've tried everything I could think of.

luanfreitasdev commented 2 years ago

Hello, thanks for report this bug

https://github.com/Power-Components/livewire-powergrid/releases/tag/v2.4.9