Problem/Motivation

In #3095740-30: Convert menu_link_content, menu_ui module hook_help() to topic(s), @catch rightfully pointed out that we should be consistent in our help topics for the menu* system/module, with the term "menu link" and not call them "menu items".

However, the menu UI is not completely consistent.

As a note, the API docs in menu_ui.module nearly consistently call things "menu items", but this issue is not asking for that to change.

Here are the places where "item" is used instead of "link" under core/modules/menu_ui (excluding tests, which will most likely also need updates if they fail when the UI is updated):

./src/Plugin/Validation/Constraint/MenuSettingsConstraint.php:  public $messageWeight = 'You can only change the menu item weight for the <em>published</em> version of this content.';
./src/Plugin/Validation/Constraint/MenuSettingsConstraint.php:  public $messageParent = 'You can only change the parent menu item for the <em>published</em> version of this content.';
./src/Plugin/Validation/Constraint/MenuSettingsConstraint.php:  public $messageRemove = 'You can only remove the menu item in the <em>published</em> version of this content.';
./menu_ui.module:  $form['menu']['link']['menu_parent']['#title'] = t('Parent item');
./menu_ui.module:    '#title' => t('Default parent item'),
./menu_ui.module:    '#description' => t('Choose the menu item to be the default parent for a new link in the content authoring form.'),
./menu_ui.module:      $form_state->setErrorByName('menu_parent', t('The selected menu item is not under one of the selected menus.'));

And here is the one place under core/modules/menu_link_content that say "item" -- especially interesting, it uses both "link" and "item" in the same UI string?!?:

/src/Plugin/migrate/source/MenuLink.php:      'hidden' => t('A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link)'),

There are also a few pages in other modules (see comment #12).

Proposed resolution

Fix the UI text so that it consistently refers to menu links and not menu items, throughout Drupal core.

Remaining tasks

Make a patch, and get the tests to pass.

User interface changes

Consistent terminology for menu links.

Before patch:

After patch:

API changes

No.

Data model changes

No.

Release notes snippet

Not needed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon created an issue. See original summary.

jhodgdon’s picture

Status: Active » Needs review
Issue tags: +Usability
FileSize
8.91 KB

Here's a patch. I found a few places in System module as well, and changed them too, including the name of the permission for administering menus and menu links.

I expect the tests to pass, as I didn't try to find the tests that might refer to UI text having the phrase "menu item" in it.

Status: Needs review » Needs work

The last submitted patch, 2: 3158562-1.patch, failed testing. View results

jhodgdon’s picture

Status: Needs work » Needs review
FileSize
11.73 KB
2.85 KB

As expected, there were a few tests that checked for UI text that needed adjustment.

jhodgdon’s picture

Issue tags: +Needs screenshots

If someone wants to make before/after screenshots of various pages in the menu UI, showing it saying both "link" and "item" before the patch, and just "link" after the patch, it could be helpful. Thanks!

pameeela’s picture

@jhodgdon, added screenshots to IS. With the patch there is still one instance of 'menu item' in the 'Expand all menu items' setting for menu blocks:

Also I was unable to trigger the error 'The selected menu item is not under one of the selected menus.' Anyone know a good way to do this? Or can we just verify via the patch? I tried creating a menu link in a node and then updating the content type settings to change the available menus, but the node edit form correctly updated in every case.

pameeela’s picture

Status: Needs review » Needs work
Issue tags: -Needs screenshots
pameeela’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
9.2 KB
9.21 KB
12.27 KB

Updated patch and some more screenshots.

pameeela’s picture

FileSize
697 bytes

Interdiff for good measure :)

jhodgdon’s picture

Your change looks good to me, and thanks for making all of those screenshots too, and finding that one place I missed! Now we need to find someone else to review the patch (both of us worked on it, so it would be best to have a different reviewer). And yes, I think the test is sufficient for verifying the error message.

Kristen Pol’s picture

Issue tags: +Bug Smash Initiative

I'm going to review now. Tagging for Bug Smash!

Kristen Pol’s picture

Status: Needs review » Needs work

Thanks for the update. The issue summary says we are supposed to focus on menu_ui yet I do see some code outside of that changed:

  • core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php
  • core/modules/system/src/Plugin/Block/SystemMenuBlock.php
  • core/modules/system/system.permissions.yml

So... I checked for any remaining "menu item" and "parent item" that were not in 1) tests, 2) comments, or 3) backend code like schemaDefinition.

If we are to change *any* UI-facing code, then I see a few more things that appear to be shown to the user:

"menu item":

  • core/modules/forum/forum.module (forum_help): "...provides a default <em>Forums</em> menu item..."
  • core/modules/shortcut/shortcut.module (shortcut_help): "...provides a corresponding menu item..."
  • core/modules/toolbar/toolbar.info.yml (description): "...top-level administration menu items and links..."
  • core/modules/views/src/Plugin/views/display/Page.php (various places, e.g. in optionsSummary): e.g. $options['menu']['setting'] = $this->t('Parent menu item');

"parent item":

  • core/modules/views/src/Plugin/views/display/Page.php (buildOptionsForm): "...The path of a parent item..."

If these shouldn't be included, let me know and I'll just focus on the changes in the patch.

jhodgdon’s picture

Issue summary: View changes

Thanks! Yes, I think we should fix it everywhere. Updating the issue summary. Thanks for the more thorough check!

jhodgdon’s picture

@pameeela, do you want to make the next patch? :)

dww’s picture

Thanks for working on this! I love efforts to make Drupal more consistent and self-documenting. A menu "link" makes much more sense to mere mortals than an "item".

Patch looks really good (so far). Nothing to complain about that's already here.

However, this line from the summary concerns me:

As a note, the API docs in menu_ui.module nearly consistently call things "menu items", but this issue is not asking for that to change.

IMHO, if the scope of this issue is 'Consistently refer to "menu links" as that, not "menu items"' I'm not sure why we should restrict it to the UI. It's a pet peeve to have the docs diverge from what they're documenting. Why not fix all of this at once?

So NW for either an expanded patch/scope here, or a follow-up to fix everything we're leaving out:

Before:

% grep -ir --exclude='node_modules' --exclude='LICENSE.txt' 'menu item' core | wc
     219    4400   41252

After:

% grep -ir --exclude='node_modules' --exclude='LICENSE.txt' 'menu item' core | wc
     205    4044   37940

A brief example of those 205 hits:

core/lib/Drupal/Core/Menu/MenuLinkTreeInterface.php: * The menu item's LI element is given one of the following classes:

IMHO that's just weird: a class called "MenuLinkTreeInterface" that's talking about a "menu item"... 😉

Thanks/sorry,
-Derek

p.s. I also noticed we've got some hits for "menuitem", too:

 grep -ir --exclude='node_modules' --exclude='LICENSE.txt' 'menuitem' core | wc
      51    5168  203883

p.p.s. Ooof, x-post. Yeah, +1 to #12 - #14. ;)

jhodgdon’s picture

Yeah, let's make a separate issue for the API docs. It's most likely even worse than grepping 'menu item', as sometimes it might say "Something something menu has an item" or might have "menu" at the end of the line and "item" at the start of the next. And don't forget "parent item".

With this in mind... I went to localize.drupal.org, downloaded a PO file for 9.0.2, and searched for UI strings containing "item" or "Item", found a few more, and then figured out where they are. Usually, "item" is referring to an aggregator feed item, a content item, or some kind of generic word. But there are a few more referring to menu items, or to shortcut items (which are also links) and toolbar items (which I think are also links?)... So, I think we also need to fix (paths are relative to /core):

modules/menu_ui/src/Form/MenuDeleteForm.php:      ... system-defined items will be reset ... [appears at least twice in this file]
modules/shortcut/shortcut.module:      ... provides a corresponding menu item....
modules/shortcut/src/ShortcutSetForm.php:      ... copying items from your default shortcut set.'),
modules/shortcut/src/Form/SwitchShortcutSet.php:       ... copying items from your default shortcut set.'), [several things in this file]
lib/Drupal/Core/Menu/MenuTreeStorage.php:      ... a disabled menu item that may be shown on admin screens
modules/toolbar/src/Element/Toolbar.php:        ...  $this->t('Toolbar items'), [several things in this file]
modules/shortcut/src/Plugin/migrate/source/d7/Shortcut.php:   ...    primary key for this menu item ...

I'm not entirely sure about the toolbar ones.... we may need to think about that a bit....

dww’s picture

Okay, sounds reasonable. Follow-up opened as a child issue:

#3159213: Consistently refer to "menu links" as that, not "menu items", in code comments and docs

Needs follow-up 😉

Still NW for #12 and #16.

Thanks,
-Derek

jhodgdon’s picture

It seems that Toolbar should not be talking about links, except in the case of menus that are added to the toolbar, because toolbar "items" are actually "trays" with "toggles". See https://api.drupal.org/api/drupal/core%21modules%21toolbar%21toolbar.api... for more info.

Anyway, here's a patch that fixes the rest of the things in #12 and #16, at least I think so.

dww’s picture

FileSize
27.21 KB
1.33 KB

"Patch failed to apply". It's just minor fuzz due to #3155258: Use American English spelling of "gray"

Here's a trivial re-roll. Interdiff is empty, it's only s/grey/gray/ in a context line that's different, so here's a raw diff of the 2 patch files, instead.

jhodgdon’s picture

Thanks for that! I think I had the previous patch already applied, and didn't do the stash/pull/stash apply to make sure the repo was updated. Silly me!

sime’s picture

I picked up a few more (looks like a lot more but here are a few) and I could make a new patch. Are these in scope?

In system/templates/admin-block-content.html.twig

the array represents an administrative menu item

In seven/templates/admin-block-content.html.twig

* - content: List of administrative menu items. Each menu item contains:
...
* - description: Description of the administrative menu item.

In MenuLinkTreeInterface.php

lib/Drupal/Core/Menu/MenuLinkTreeInterface.php:82:   * The menu item's LI element is given one of the following classes:
lib/Drupal/Core/Menu/MenuLinkTreeInterface.php:83:   * - expanded: The menu item is showing its submenu.
lib/Drupal/Core/Menu/MenuLinkTreeInterface.php:84:   * - collapsed: The menu item has a submenu that is not shown.
lib/Drupal/Core/Menu/MenuLinkTreeInterface.php:85:   * - leaf: The menu item has no submenu.
lib/Drupal/Core/Menu/MenuLinkTreeInterface.php:108:   *   The ID of an item in the storage.
dww’s picture

@sime: Thanks, but all of those are comments, and therefore in scope for #3159213: Consistently refer to "menu links" as that, not "menu items", in code comments and docs, not here.

Cheers,
-Derek

sime’s picture

Looks good. I've applied the patch. I've visually eye-balled each change in the patch. I grepped code for " item" then went through each reference to menu and confirmed there are no more end user facing references to "menu item".

sime’s picture

Status: Needs review » Reviewed & tested by the community

  • catch committed dcec533 on 9.1.x
    Issue #3158562 by jhodgdon, pameeela, dww, sime, Kristen Pol:...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Looks good to me - reviewing the patch you can see us switching between item and link in the same sentence, let alone across the module.

Committed dcec533 and pushed to 9.1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.