@@ -31,12 +31,20 @@ class ManageMenuItems extends Page implements HasActions, HasForms
31
31
32
32
public mixed $ record ;
33
33
34
+ public $ refreshKey = 0 ;
35
+
34
36
public function mount (int |string $ record ): void
35
37
{
36
38
$ menuModel = static ::getResource ()::getModel ();
37
39
$ this ->record = $ menuModel ::findOrFail ($ record );
38
40
}
39
41
42
+ protected function refreshTree (): void
43
+ {
44
+ $ this ->refreshKey ++;
45
+ $ this ->dispatch ('menu-items-updated ' );
46
+ }
47
+
40
48
public function getTitle (): string
41
49
{
42
50
return flexiblePagesTrans ('menu_items.manage.title ' , [
@@ -220,7 +228,7 @@ public function deleteMenuItem(int $itemId): void
220
228
// Delete the item
221
229
$ item ->delete ();
222
230
223
- $ this ->dispatch ( ' menu-items-updated ' );
231
+ $ this ->refreshTree ( );
224
232
225
233
Notification::make ()
226
234
->title (flexiblePagesTrans ('menu_items.messages.item_deleted ' ))
@@ -246,7 +254,7 @@ public function confirmDeleteWithChildren(int $itemId): void
246
254
// Delete the item and all its descendants
247
255
$ item ->delete ();
248
256
249
- $ this ->dispatch ( ' menu-items-updated ' );
257
+ $ this ->refreshTree ( );
250
258
251
259
Notification::make ()
252
260
->title (flexiblePagesTrans ('menu_items.messages.item_and_children_deleted ' ))
@@ -302,7 +310,7 @@ public function reorderMenuItems(array $orderedItems): void
302
310
// Process the reordering with proper nested set operations
303
311
$ this ->processNestedSetReorder ($ orderedItems );
304
312
305
- $ this ->dispatch ( ' menu-items-updated ' );
313
+ $ this ->refreshTree ( );
306
314
307
315
Notification::make ()
308
316
->title (flexiblePagesTrans ('menu_items.messages.items_reordered ' ))
@@ -506,7 +514,7 @@ public function moveMenuItem(int $itemId, ?int $newParentId = null, ?int $afterI
506
514
}
507
515
}
508
516
509
- $ this ->dispatch ( ' menu-items-updated ' );
517
+ $ this ->refreshTree ( );
510
518
511
519
Notification::make ()
512
520
->title (flexiblePagesTrans ('menu_items.messages.item_moved ' ))
@@ -702,7 +710,7 @@ public function createMenuItem(array $data): void
702
710
->send ();
703
711
704
712
// Refresh the menu items tree view
705
- $ this ->dispatch ( ' menu-items-updated ' );
713
+ $ this ->refreshTree ( );
706
714
707
715
} catch (Exception $ e ) {
708
716
Notification::make ()
@@ -756,7 +764,7 @@ public function updateMenuItem(int $itemId, array $data): void
756
764
->send ();
757
765
758
766
// Refresh the menu items tree view
759
- $ this ->dispatch ( ' menu-items-updated ' );
767
+ $ this ->refreshTree ( );
760
768
761
769
} catch (Exception $ e ) {
762
770
Notification::make ()
0 commit comments