From 0036907db6ed79ac2d8ac7425a08e554a2c92074 Mon Sep 17 00:00:00 2001 From: fajar sp Date: Fri, 1 Mar 2024 06:35:34 +0700 Subject: [PATCH] bug fix toggle column not working on first time toogling (#1431) * bug fix toggle column not working on first time toogling after refresh browser * Fix phpstan, add x-clock --------- Co-authored-by: luanfreitasdev --- .../frameworks/tailwind/header/export.blade.php | 1 + .../tailwind/header/toggle-columns.blade.php | 1 + src/Concerns/Listeners.php | 16 ++++++++++------ src/PowerGridComponent.php | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/resources/views/components/frameworks/tailwind/header/export.blade.php b/resources/views/components/frameworks/tailwind/header/export.blade.php index c8325493..439343b1 100644 --- a/resources/views/components/frameworks/tailwind/header/export.blade.php +++ b/resources/views/components/frameworks/tailwind/header/export.blade.php @@ -13,6 +13,7 @@ class="pg-btn-white dark:ring-pg-primary-600 dark:border-pg-primary-600 dark:hov
visibleColumns as &$column) { - if (data_get($column, 'field') === $field) { - data_set($column, 'hidden', !data_get($column, 'hidden')); + $this->visibleColumns = $this->visibleColumns->map(function (\stdClass | array $column) use ($field) { + if (is_object($column) && $column->field === $field) { + $column->hidden = !$column->hidden; + } - break; + if (is_array($column) && $column['field'] === $field) { + $column['hidden'] = !$column['hidden']; } - } + + return $column; + }); $this->persistState('columns'); } diff --git a/src/PowerGridComponent.php b/src/PowerGridComponent.php index 1c857720..381beb73 100644 --- a/src/PowerGridComponent.php +++ b/src/PowerGridComponent.php @@ -20,7 +20,7 @@ /** * @property-read mixed $getCachedData * @property-read bool $hasColumnFilters - * @property-read array|BaseCollection $visibleColumns + * @property array|BaseCollection $visibleColumns */ class PowerGridComponent extends Component {