magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.52k stars 9.31k forks source link

Columns functionality for \Magento\Theme\Block\Html\Topmenu seems broken #38326

Open ioweb-gr opened 9 months ago

ioweb-gr commented 9 months ago

Summary

I'm trying to customize the topmenu without adding 3rd party modules.

I noticed that \Magento\Theme\Block\Html\Topmenu::getHtml has the possibility to add a limit and also columns should be possible to add with the built in functionality \Magento\Theme\Block\Html\Topmenu::shouldAddNewColumn

However when setting the value for limit to 10 in default.xml

e.g.

                        <arguments>
                            <argument name="columns_limit" xsi:type="number">10</argument>
                        </arguments>

I get greeted with errors if there's a menu item with less than 10 children

And when using a number that's acceptable for all menu items like 5 then the submenu doesn't render fully.

There's no documentation in the source code or the docs about the built-in functionality which seems partially broken.

Could someone from the core developers let us know if this functionality should be usable (should be working) and perhaps an example for using it?

Examples

Create a menu item with 50 sub categories and try to columnize using

                        <arguments>
                            <argument name="columns_limit" xsi:type="number">10</argument>
                        </arguments>

In the topnav block.

menu.tar.gz

Proposed solution

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 9 months ago

Hi @ioweb-gr. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

ioweb-gr commented 9 months ago

To add some more observations, it seems that it does render the items grouped in columns but the CSS is not proper for the change. So apart from the exception, the problem must be that the CSS is not taking this situation into account to render the columns even though the functionality is there

m2-assistant[bot] commented 9 months ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 9 months ago

Hello @ioweb-gr,

Thank you for the report and collaboration!

We were able to reproduce this issue on 2.4-develop. Please look at the screenshot below: When adding the column limit less then the total number of sub-menu, we didn't get any error, but the sub-menu was not being displayed.

image

And when the limit was set higher then the total number of sub-menu, we got the error. Also this error will be thrown if each menu has different number of sub-menu.

image

Hence confirming this issue.

Thank you.

github-jira-sync-bot commented 9 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-10756 is successfully created for this GitHub issue.

m2-assistant[bot] commented 9 months ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.