magento2: Backend menu gets too long and not generating proper columns

Preconditions and environment

  • Magento version 2.4.4-p4
  • Firefox
  • Having a first submenu containing more than 12 items.

Example : the first submenu of the Sales menu has got 13 items.

image

Steps to reproduce

  1. Access the backend.

Expected result

The system should add a column brake so the submenus are correctly displayed

Actual result

Unable to access submenus below the 12+ submenu because the column brake isn’t behaving correctly.

Attached is a screenshot of the problem. I’m already scrolled down at the very bottom of the page and there’s still items below “Shipments” and “Credit memos”

image

Additional information

I have investigated and managed to fix the issue with the following code. Problem comes from the fact that if the first submenu exceeds the hardcoded 12 items limit, the next submenu does not automatically include a column brake.

diff --git a/magento/module-backend/Block/Menu.php b/magento/module-backend/Block/Menu.php
--- a/magento/module-backend/Block/Menu.php
+++ b/magento/module-backend/Block/Menu.php
@@ -333,10 +333,16 @@ class Menu extends \Magento\Backend\Block\Template
         }
         $result[] = ['total' => $total, 'max' => ceil($total / ceil($total / $limit))];
         $count = 0;
+        $itemCount = 0;
+        $nextColBrake = false;
         foreach ($items as $item) {
+            $itemCount++;
             $place = $this->_countItems($item->getChildren()) + 1;
             $count += $place;
-            if ($place - $result[0]['max'] > $limit - $result[0]['max']) {
+            if ($nextColBrake) {
+                $colbrake = true;
+                $count = $place;
+            } elseif ($place - $result[0]['max'] > $limit - $result[0]['max']) {
                 $colbrake = true;
                 $count = 0;
             } elseif ($count - $result[0]['max'] > $limit - $result[0]['max']) {
@@ -345,6 +351,12 @@ class Menu extends \Magento\Backend\Block\Template
             } else {
                 $colbrake = false;
             }
+
+            $nextColBrake = false;
+            if ($itemCount == 1 && $colbrake) {
+                $nextColBrake = true;
+            }
+
             $result[] = ['place' => $place, 'colbrake' => $colbrake];
         }
         return $result;

Test evidence after fix :

image

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Hello @digitalpianism,

Thank you for report and collaboration!

We have reproduced the issue on 2.4-develop. We can observe that it is not possible to access the rest of the menu, if there are more than 12 submenu. Please look at the screenshot for reference. image

Hence confirming the issue. Thanks.

Hi @digitalpianism

Thank you for reporting and collaboration.

“Amasty Extension” that doesn’t come along with latest / default Magento installation. Code of this package is not part of https://github.com/magento/magento2 git repository. We are not able to provide fix for it in this repository. All questions, issue reports and fix for them should be addressed to the corresponding extension owners(support) or the Magento Market place page

Thank you.