Skip to content

Commit aa73cb0

Browse files
committed
Remove drag and drop reordering and work with btns.
1 parent b22ddc0 commit aa73cb0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

resources/views/filament/resources/menu-resource/pages/manage-menu-items.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class="space-y-6"
2626
@else
2727
<!-- Tree Items -->
2828
<div class="space-y-2" id="menu-items-container" wire:key="tree-{{ $refreshKey }}">
29-
@foreach($this->record->menuItems()->with(['children', 'linkable'])->whereNull('parent_id')->orderBy('_lft')->get() as $item)
29+
@foreach($this->getTreeItems() as $item)
3030
@livewire('filament-flexible-content-block-pages::menu-tree-item', [
3131
'item' => $item,
3232
'maxDepth' => $this->getMaxDepth()

src/Resources/MenuResource/Pages/ManageMenuItems.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class ManageMenuItems extends Page implements HasActions, HasForms
3232
public mixed $record;
3333

3434
public $refreshKey = 0;
35+
36+
public $menuItems = null;
3537

3638
public function mount(int|string $record): void
3739
{
@@ -72,6 +74,16 @@ public function getMenuItems(): array
7274
return $this->buildTree($items->toArray());
7375
}
7476

77+
public function getTreeItems()
78+
{
79+
// Force fresh query every time
80+
return $this->record->menuItems()
81+
->with(['children', 'linkable'])
82+
->whereNull('parent_id')
83+
->orderBy('_lft')
84+
->get();
85+
}
86+
7587
protected function buildTree(array $items, $parentId = null): array
7688
{
7789
$tree = [];
@@ -921,6 +933,8 @@ public function moveItemUp(int $itemId): void
921933
$previousSibling = $item->getPrevSibling();
922934
if ($previousSibling) {
923935
$item->beforeNode($previousSibling)->save();
936+
937+
// Refresh the tree to show new order
924938
$this->refreshTree();
925939

926940
Notification::make()
@@ -952,6 +966,8 @@ public function moveItemDown(int $itemId): void
952966
$nextSibling = $item->getNextSibling();
953967
if ($nextSibling) {
954968
$item->afterNode($nextSibling)->save();
969+
970+
// Refresh the tree to show new order
955971
$this->refreshTree();
956972

957973
Notification::make()

0 commit comments

Comments
 (0)