Problem/Motivation

Cannot expand toolbar items referencing "<nolink>" or with options "_no_path". There is no arrow.
This only happens when the toolbar is on the left side.

With core itself cannot expand any if at the top (works as expected), and contrib module admin_toolbar works properly in that use case.

Problem with childe menu items under no-link parent items

Version 10.1.x-dev shows a span without correct styling.
Same problem on 10.1.x-dev plus styling issue

Steps to reproduce

  1. Install a clean version of Drupal 10.1.x-dev
  2. Optional: Install and enable the Admin Toolbar contrib module
  3. Add a menu item to a menu rendered in toolbar on the first navigation level below the "Administration" link.
  4. Use <nolink> in the path field of the menu item created in the previous step and mark the link as expanded
  5. Add one or more sub-menu items under menu item created in the previous two steps
  6. Activate the "Vertical orientation" button on the toolbar (typically at the far right).
  7. The toolbar will now be rendered vertically, all menu items of the first level in one column
  8. The menu items with sub items have a blue dot with arrow down - by a click on this icon you can reach their sub menu items. This icon is missing for the menu item with <nolink>

Proposed resolution

Ensure it has the "arrow" for expanding as any other menu item.

Originally posted by user tobiberlin in a duplicate issue:
In toolbar.menu.js or toolbar.menu.es6.js I think the method initItems() should use a class as a selector instead of the a tag as there are menu items allowed without link.
---
Initialize items and their links by adding the target element on ititItems at core/modules/toolbar/js/toolbar.menu.js, line 104.

--$menu.find('li > a').wrap('<div class="toolbar-box">');
++$menu.find('li > a, li > span').wrap('<div class="toolbar-box">');

The CSS for span tag was appended with Class selector span[class*="toolbar-icon-menu-link-content:"] to avoid effects on other unrelated span tags underbutton tag.

Remaining tasks

User interface changes

API changes

Release notes snippet

Issue fork drupal-3198565

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

penyaskito created an issue. See original summary.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

tinto’s picture

This issue is referring to functionality that is added by the Admin Toolbar contrib module. Moving this issue from core to admin_toolbar issue queue.

A duplicate issue was posted later here. I'm updating this issue summary with some of the information posted there in order to improve/simplify the steps to reproduce and to add a proposed solution.

tinto’s picture

Project: Drupal core » Admin Toolbar
Version: 10.1.x-dev » 3.2.1
Component: toolbar.module » Code
tinto’s picture

Issue summary: View changes
StatusFileSize
new75.23 KB

Adding screenshot to illustrate the problem

tedfordgif’s picture

Project: Admin Toolbar » Drupal core
Version: 3.2.1 » 10.1.x-dev
Component: Code » ajax system
StatusFileSize
new30.65 KB

This is a problem even without admin_toolbar, so moving back to core. See attached screenshot.

tedfordgif’s picture

Component: ajax system » toolbar.module

Component got messed up, apologies.

tedfordgif’s picture

Issue summary: View changes
tedfordgif’s picture

Issue summary: View changes
g-brodiei’s picture

Issue summary: View changes

Updating issue summary with image from @tedfordgif

g-brodiei’s picture

IMHO, I'm seeing two part of this issue needs to be handled.

  1. The styling for <nolink> menu item
  2. The expand button for <nolink> menu item that has children menu items (either link or nolink)

What is the approach for initItems? Should we target span by a tag element or another class?

Currently the expand button may be shown by adding the target element on ititItems at core/modules/toolbar/js/toolbar.menu.js, line 104.

      // Initialize items and their links.
      $menu.find('li > a').wrap('<div class="toolbar-box">');
      // Initialize items and their links.
      $menu.find('li > a, li > span').wrap('<div class="toolbar-box">');

Screenshot of sidebar after change.
Not expanded
sidebar nolink menu item not expanded

Expanded
sidebar nolink menu item expanded

Added a patch to display workable change without proper styling.

benjifisher’s picture

Status: Active » Needs work
Issue tags: +Usability, +Needs tests

We discussed this issue at #3324991: Drupal Usability Meeting 2022-12-09. That issue will have a link to a recording of the meeting.

For the record, the attendees at today's usability meeting were @Antoniya, @benjifisher, @g-brodiei, @rkoller, and @simohell.

We agree that this issue is a usability bug, and I am adding the issue tag for that. The usability team usually does not have an opinion on how to implement an issue.


I notice that there is a patch attached to Comment #14, so the status should not be Active. The comment points out that the styling still needs work, so I am setting the status to NW, not NR.

A bugfix usually needs to include automated tests, in order to make sure that future code changes do not cause regressions. I am adding the issue tag for that, too. The Toolbar module already has two Nightwatch tests, and we can probably add a few lines to one of those.

g-brodiei’s picture

StatusFileSize
new5.09 KB

Thank you @benjifisher.

Updating the patch for proper styling. This includes PostCSS + CSS files on the Claro admin theme as it overrides the original CSS provided by core's toolbar module.

As for testing, I skimmed through both of the nightwatch test files, can't find any test that's related to assert newly created menu items; On the other hand, I discovered a functional test for "testExternalLink" on core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php, probably something to work on for "testNoLink"?

g-brodiei’s picture

StatusFileSize
new28.54 KB

Adding gif file to display styling after patch on Claro admin theme.

The CSS for span tag was appended with Class selector span[class*="toolbar-icon-menu-link-content:"]to avoid effects on other unrelated span tags underbutton tag.

gif video to display span button styling and action on vertical orientation

arunkumark’s picture

StatusFileSize
new215.09 KB
new66.88 KB

Verified the patch #16 manually on Drupal 10.0.7. The patch was applied cleanly and worked as expected.

Attached is a screenshot after applying the patch.

Applying Patch:
QAply patch

After Applying Patch:
Apply patch

g-brodiei’s picture

Status: Needs work » Needs review

Setting status to needs review, still needs tests to be written

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

#16 failed to apply

Issue summary should be updated with the definitive proposed solution.

As mentioned tests are still needed.

sahil.goyal’s picture

Issue summary: View changes
StatusFileSize
new5.04 KB
new601 bytes

Updating the patch #16 as it failed to apply. the patch solves the issue. Updating the issue summery with proposed resolution.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

dydave’s picture

StatusFileSize
new5.06 KB

Rerolled the patch from #21 to apply to 10.2.7.

The patch seems to fix the issue.

Thanks everyone for the help!

yonailo’s picture

Hello,

The latest patch #23 seems to break CSS aggregation for me.

yonailo’s picture

StatusFileSize
new170.65 KB

It is missing a "-" character at this place :

missing char

yonailo’s picture

StatusFileSize
new5.08 KB

Rerolled patch #23 with the previous bug fixed

tinto’s picture

Status: Needs work » Needs review

I've created a MR that applies the patch in #26 (double checked: issue still exists, patch still applies, patch fixes the issue).

Can anybody please confirm that this needs test coverage? I'm asking, because I cannot find any existing tests that verify if the expand functionality works for normal links, so it seems a bit odd to write a test only for <nolink> items. Thanks!

snehal-chibde’s picture

Hello, i have tested this and have few observations as below.
I added a menu item with and set to expanded and added a sub item below it - After applying the MR the expand collapse functionality worked fine.
The patch 26 fails to apply so styling could not be checked.

Next, I also checked by adding menu item with a normal link, and set to expanded and added a sub item below it and checked, the menu item is not correctly shown.

Added screenshots for reference.

smustgrave’s picture

Status: Needs review » Needs work

Definitely think we would still need test coverage. Can almost say if we had test coverage before this bug may not have popped up.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

jvizcarrondo made their first commit to this issue’s fork.

jvizcarrondo’s picture

Status: Needs work » Needs review

I have created a new Merge Request based on the 11.x branch to resolve this issue, as the previous forks were outdated or had conflicts.
Changes made:
* Fixed js/toolbar.menu.js to open items submenu (javascript now added open/close feature a links and )
* Fixed /css/toolbar.module.css and /css/toolbar.theme.css para mejora visual
* Added new /FunctionalJavascript to test problem

I've verified the changes locally and they are ready for review.

penyaskito’s picture

MRs need to be against main first. They will be backported at maintainers discretion (being a bug fix, quite probably it will)

penyaskito’s picture

🤦🏽😅 Ohwait, there was an already existing MR against main. Reverted my change.

smustgrave’s picture

Status: Needs review » Needs work

MR for main appears to be failing.

jvizcarrondo’s picture

Status: Needs work » Needs review

"I have updated the Merge Request to target the main branch and performed a rebase to resolve previous syntax errors and out-of-date dependencies.
The CI is now passing (the previous failure in testLanguageOfPartsPlugin was a random fail unrelated to my changes, as confirmed by the successful re-run).
Summary of changes:

Fixed the Toolbar bug in core/modules/toolbar.
Added a FunctionalJavascript test to cover the fix.

Ready for review.

smustgrave’s picture

Status: Needs review » Needs work

Left some small comments around the test, thanks.