Problem/Motivation

@catch:

This preview is still user-specific, which undermines having the #lazy_builder since it means the user cache context for the non-placeholdered render array too. I'm not sure we have standard patterns for this in core yet, the preview stuff is quite new, but can it use 'blurred text' or similar? Or just no preview at all maybe if it's not above the fold? The preview is mostly useful to avoid CLS.

@plopesc:go

Good catch!

My understanding was that #lazy_builder_preview was a generic placeholder and was not affected by caching properties.

Current core implementations are adding an empty placeholder like ['#markup' => '<a href="#" class="toolbar-tray-lazy-placeholder-link">&nbsp;</a>'] or just ['#markup' => '&nbsp;']

Would that help to solve the performance concerns?

Removing the placeholder completely causes some undesired glitches in the navigation bar when big_pipe is enabled

@nod_ :

static string is fine, it'll get replaced once loaded anyway

Proposed resolution

Agree on a lazy load strategy.

Remaining tasks

This issue should be resolved by the following issues. We are leaving this issue open solely to track the problem and make sure it goes away when these are resolved.

User interface changes

API changes

Data model changes

Comments

ckrina created an issue. See original summary.

ckrina’s picture

Project: Navigation » Drupal core
Version: 1.x-dev » 11.x-dev
Component: Code » navigation.module
ckrina’s picture

plopesc’s picture

Status: Active » Closed (duplicate)

We can close this given that #3443559: Regression: Shortcuts menu flickers when the page is loaded showed the way to avoid flickering with no need to make an extra effort at render array level.

Same approach could be followed in the future if necessary.

Talked to @mherchel in the weekly Drupal Admin UI call and he also agreed.

catch’s picture

Title: Agree on a lazy load strategy » User menu block render array is cached per user
Category: Task » Bug report
Status: Closed (duplicate) » Active
   */
  public function build(): array {
    return [
      'user' => [
        '#lazy_builder' => [
          'navigation.user_lazy_builder:renderNavigationLinks',
          [],
        ],
        '#create_placeholder' => TRUE,
        '#cache' => [
          'keys' => ['user_set_navigation_links'],
          'contexts' => ['user'],
        ],
        '#lazy_builder_preview' => [
          '#markup' => '<a href="#" class="toolbar-tray-lazy-placeholder-       link">&nbsp;</a>',
        ],
      ],
    ];
  }

I think there's still an issue here - it now looks like the preview isn't user-specific, but the caching of the preview still is. This could be verified by using the navigation with a couple of different users then checking the cache IDs in the cache_render table.

It could end up being a duplicate of #3441576: Add a new "Navigation user links" menu in favor of hardcoded links in NavigationUserBlock maybe though.

plopesc’s picture

Thank you for the heads up!

Planned to deal with this as part of the mentioned issue #3441576: Add a new "Navigation user links" menu in favor of hardcoded links in NavigationUserBlock once the related issues #3445993: Provide a NavigationLinkBlock Plugin and use Help as an usage example & #3446116: Rename UserNavigationBlock to NavigationUserBlock for class name consistency are in and the ground is ready to mess with it.

We can leave this open as a reference and reminder in the meantime, though.

m4olivei’s picture

Title: User menu block render array is cached per user » [PP-1] User menu block render array is cached per user
Status: Active » Postponed
Related issues: +#3445993: Provide a NavigationLinkBlock Plugin and use Help as an usage example

Postponing on #3445993: Provide a NavigationLinkBlock Plugin and use Help as an usage example (which is really close!!), per last comment by @plopsec.

mherchel’s picture

Issue summary: View changes

Updating IS

catch’s picture