Investigate using the core "User account menu" in favor of custom Navigation Block for same

Created on 17 April 2024, 2 months ago
Updated 20 May 2024, about 1 month ago

Problem/Motivation

In the current version of the module, the user Navigation block that lives at the bottom of the Navigation bar is a set of custom links defined in \Drupal\navigation\UserLazyBuilder::userOperationLinks. It is not using the "User account menu". This was brought up as a question as to why we have this approach, by catch in the core MR ( Add the new Navigation to core as an Experimental module Fixed ). Link to the specific, relevant comment:

https://git.drupalcode.org/project/drupal/-/merge_requests/7474#note_297387

It appears the current implementation has been carried as is, since early in the development lifecyle and this question hasn't had sufficient scrutiny.

A couple things would be different if we use the "User account menu". First, we would loose the "Edit profile" link. Second, the default label would be different. We currently have "View profile", core has "My account".

The task here is to investigate:

  • Do we require an "Edit profile" link, or would it be OK to loose that in using the "User account menu"?
  • Are there caching concerns of current approach vs using core menu?
  • Is there a substantive reason why we need to keep the current approach, vs using the "User account menu"?
  • What would using the core "User account menu" mean for this issue: Add the user image to the user menu when available Active ?
📌 Task
Status

Active

Version

11.0 🔥

Component
Navigation 

Last updated about 11 hours ago

No maintainer
Created by

🇨🇦Canada m4olivei Grimsby, ON

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @m4olivei
  • 🇨🇦Canada m4olivei Grimsby, ON
  • 🇨🇦Canada m4olivei Grimsby, ON
  • 🇨🇦Canada SKAUGHT

    Navigation project goals include: Add the user image to the user menu when available Active

    How User menu is made: User menu is provided by a Menu Plugin (YAML FORMAT)
    https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/user/...

    user login/logout item:
    https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/user/...
    items itself dynamically changes title & path. cache content 'user.roles:authenticated'

    ----
    Perhaps it's simply that using the same namespace 'user' should be renamed to keep more separation for when a site may want to place the traditional list of Account Items?

    #[NavigationBlock(
      id: 'user',
      admin_label: new TranslatableMarkup('User'),
    )]
    
  • 🇬🇧United Kingdom catch

    If this needs to be different to the user account menu that would normally be in the front end theme (brought up by @ckrina on the MR), then it might also be possible to define an additional menu like 'Navigation user links' so that they're separate - but that would still allow people to add an extra link or remove something if they want to.

  • 🇪🇸Spain ckrina Barcelona

    Agreed. I missed the part about customizing the links. Tagging this as Stable Blocker.

  • 🇪🇸Spain ckrina Barcelona
  • 🇬🇧United Kingdom AaronMcHale Edinburgh, Scotland

    Having the "User account menu" and the user account links that appear in the toolbar being different does feel like a weird quirk, from a UX perspective I think using the "User account menu" and "modernizing" it makes a lot of sense. As noted, it also allows the user menu links in the toolbar to be customized, which is a win in my opinion. I think it would be weird if every other menu in the Navigation could be customized apart from the user links.

  • 🇬🇧United Kingdom catch

    There are sites that customize the user account menu links with links that they might not want in the navigation toolbar, however, if it's just a menu block in the layout, those sites could swap it out with a different menu block easily enough. So using the same block by default might be plenty?

  • 🇬🇧United Kingdom AaronMcHale Edinburgh, Scotland

    however, if it's just a menu block in the layout, those sites could swap it out with a different menu block easily enough. So using the same block by default might be plenty?

    Agreed. We should think in terms of what's the most sensible default for the 89% use-case. As you say, they can always use a different menu on the front-end, or swap this one out for a different one in the navigation.

  • 🇪🇸Spain plopesc Valladolid

    Adding 📌 Agree on a lazy load strategy Active as reference to deal with caching at user level issues.

    My concern or question about how to integrate a menu here is because most of the links I think that could be added to this menu are user specific, like /user/XX/foo and I am not sure how we could handle routes like that from a menu.

    Mostly thinking about menu links created from the UI by site admins, where it is not possible to indicate URL parameters.

    Core's user routes provides shortcuts like /user or /user/edit that redirects to the user specific page, but that's something not all the contrib modules that provide user specific routes or views that use the user ID as parameter would support.

    We could encourage the usage of modules like https://www.drupal.org/project/user_current_paths or https://www.drupal.org/project/me_redirect for this menu, though.

Production build 0.69.0 2024