diff --git a/packages/actions/docs/05-grouping-actions.md b/packages/actions/docs/05-grouping-actions.md index 5055baf897..71fa8e2ba8 100644 --- a/packages/actions/docs/05-grouping-actions.md +++ b/packages/actions/docs/05-grouping-actions.md @@ -44,27 +44,18 @@ ActionGroup::make([ ## Adding dividers between actions -You may add dividers between each action in the dropdown by using the `divided()` method: +You may add dividers between groups of actions by using nested `ActionGroup` objects: ```php ActionGroup::make([ + ActionGroup::make([ + // Array of actions + ])->dropdown(false), // Array of actions ]) - ->divided() ``` -If you'd like to group multiple actions together within one division, you may nest another `ActionGroup` within the main `ActionGroup`, and disable the dropdown on the nested group using `dropdown(false)`: - -```php -ActionGroup::make([ - // Array of individually divided actions - ActionGroup::make([ - // Array of actions within one division - ])->dropdown(false), - // Array of individually divided actions -]) - ->divided() -``` +The `dropdown(false)` method puts the actions inside the parent dropdown, instead of a new nested dropdown. ## Setting the width of the dropdown diff --git a/packages/actions/resources/views/components/group.blade.php b/packages/actions/resources/views/components/group.blade.php index 0f8442fdbb..c39bf912e8 100644 --- a/packages/actions/resources/views/components/group.blade.php +++ b/packages/actions/resources/views/components/group.blade.php @@ -53,29 +53,31 @@ @endforeach @else @php - $actions = array_filter( - $group->getActions(), - fn ($action): bool => $action->isVisible(), - ); - $actionLists = []; - $actionList = []; + $singleActions = []; + + foreach ($group->getActions() as $action) { + if ($action->isHidden()) { + continue; + } - foreach ($actions as $action) { if ($action instanceof \Filament\Actions\ActionGroup && (! $action->hasDropdown())) { - if (count($actionList)) { - $actionLists[] = $actionList; - $actionList = []; + if (count($singleActions)) { + $actionLists[] = $singleActions; + $singleActions = []; } - $actionLists[] = $action->getActions(); + $actionLists[] = array_filter( + $action->getActions(), + fn ($action): bool => $action->isVisible(), + ); } else { - $actionList[] = $action; + $singleActions[] = $action; } } - if (count($actionList)) { - $actionLists[] = $actionList; + if (count($singleActions)) { + $actionLists[] = $singleActions; } @endphp