rappasoft / laravel-livewire-tables

A dynamic table component for Laravel Livewire
https://rappasoft.com/docs/laravel-livewire-tables/v2/introduction
MIT License
1.7k stars 319 forks source link

[Bug]: hideBulkActionsWhenEmpty is not working #1703

Open rpringadi opened 2 months ago

rpringadi commented 2 months ago

What happened?

My understanding is if we want to keep showing the bulk action button, we can do the following:

        $this->hideBulkActionsWhenEmpty = false;
        $this->setHideBulkActionsWhenEmptyStatus(false);

I tried that, but that doesn't work. Looking into the code closely, we have this file:

// resources/js/laravel-livewire-tables.js  - line 11

alwaysShowBulkActions: !wire.entangle('hideBulkActionsWhenEmpty'),

The wire.entangle('hideBulkActionsWhenEmpty'), actually returns an object instead of a simple true/false.

{
  "initialValue": false,
  "_x_interceptor": true
}

I guess the proper code should be the following? -- just guessing.

alwaysShowBulkActions: !wire.entangle("hideBulkActionsWhenEmpty").initialValue,

How to reproduce the bug

  public function configure(): void
    {
        ...
        $this->hideBulkActionsWhenEmpty = false;
        $this->setHideBulkActionsWhenEmptyStatus(false);
    }

Package Version

3.2.4

PHP Version

8.2.x

Laravel Version

10.48.4

Alpine Version

3.13.8

Theme

Tailwind 3.x

Notes

No response

Error Message

No response

lrljoe commented 2 months ago

Won't be initial value, as the entangle keeps it synchronised with the backend. Certainly not working though, will have to see where it became broken, give me til the end of the week.

stale[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

lrljoe commented 1 month ago

Will be fixed very soon!

shawe commented 1 day ago

Interested in the same issue, I see now that alwaysShowBulkActions never changes to true.

lrljoe commented 1 day ago

Yeah, it's on the to-do list for the next week, apologies for the delay. I've got a local fix, which corrects the issue, and also renames the JS property so that it matches the backend.

Should be in next week, PR is here #1747 and it is now in the "development" branch (should you wish to test!).