This commit is contained in:
Dan Harrin
2023-05-17 13:23:52 +01:00
parent 74e81f2bc8
commit 4730e1e199
2 changed files with 21 additions and 28 deletions
+5 -14
View File
@@ -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
@@ -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