diff --git a/resources/views/components/row.blade.php b/resources/views/components/row.blade.php index d3f206e2..3ef3adb3 100644 --- a/resources/views/components/row.blade.php +++ b/resources/views/components/row.blade.php @@ -46,9 +46,11 @@
@if (filled(data_get($row, 'actions')) && $column->isAction) @foreach (data_get($row, 'actions') as $key => $action) -
- {!! $action !!} -
+ @if(filled($action)) +
+ {!! $action !!} +
+ @endif @endforeach @endif
diff --git a/tests/Feature/ActionRules/HideTest.php b/tests/Feature/ActionRules/HideTest.php index 86016a20..c54ca92c 100644 --- a/tests/Feature/ActionRules/HideTest.php +++ b/tests/Feature/ActionRules/HideTest.php @@ -48,6 +48,27 @@ public function actionRules($row): array } }; +$hidePreventShowHtml = new class () extends DishTableBase { + public function actions($row): array + { + return [ + Button::add('edit') + ->slot('test') + ->id() + ->dispatch('edit', ['dishId' => $row->id]), + ]; + } + + public function actionRules($row): array + { + return [ + Rule::button('edit') + ->when(fn ($row) => $row->id === 1) + ->hide(), + ]; + } +}; + it('properly displays "hide" on edit button', function (string $component, object $params) { livewire($component, [ 'join' => $params->join, @@ -66,20 +87,20 @@ public function actionRules($row): array ]) ->group('action'); -it('properly displays "hide" on render button', function (string $component, object $params) { +it('does not show the html of actions when hide is activated', function (string $component, object $params) { livewire($component, [ 'join' => $params->join, ]) ->call($params->theme) ->set('setUp.footer.perPage', 3) - ->assertSeeHtml("render - 1") - ->assertSeeHtml("render - 2") - ->assertDontSeeHtml("render - 3"); + ->assertDontSeeHtml("action-1-render-action.0.edit") + ->assertSeeHtml("action-2-render-action.0.edit") + ->assertSeeHtml("action-3-render-action.0.edit"); }) ->with([ - 'tailwind' => [$hideWithRender::class, (object) ['theme' => 'tailwind', 'join' => false]], - 'bootstrap' => [$hideWithRender::class, (object) ['theme' => 'bootstrap', 'join' => false]], - 'tailwind join' => [$hideWithRender::class, (object) ['theme' => 'tailwind', 'join' => true]], - 'bootstrap join' => [$hideWithRender::class, (object) ['theme' => 'bootstrap', 'join' => true]], + 'tailwind' => [$hidePreventShowHtml::class, (object) ['theme' => 'tailwind', 'join' => false]], + 'bootstrap' => [$hidePreventShowHtml::class, (object) ['theme' => 'bootstrap', 'join' => false]], + 'tailwind join' => [$hidePreventShowHtml::class, (object) ['theme' => 'tailwind', 'join' => true]], + 'bootstrap join' => [$hidePreventShowHtml::class, (object) ['theme' => 'bootstrap', 'join' => true]], ]) ->group('action');