Problem/Motivation

The Navigation module provides the top_bar theme hook and
top-bar.html.twig. The Admin theme overrides it with
templates/navigation/top-bar--default-admin.html.twig, selected by an
unconditional top_bar__default_admin suggestion in
ThemeSuggestionHooks::themeSuggestionsTopBarAlter(). The suggestion always
applies, so it duplicates the template override that Drupal already resolves for
the active theme.

Proposed resolution

  • Remove themeSuggestionsTopBarAlter() from ThemeSuggestionHooks.
  • Rename the template to top-bar.html.twig.
  • Document the available variables in the template docblock.

Preprocessing uses hook_preprocess_top_bar, the base hook, so it is
unaffected. No other core code references the top_bar__default_admin
suggestion. The Admin theme is experimental, so no deprecation is added.

The landmark and accessible name for the top bar are handled in #3583486. The
rendered markup does not change here.

Remaining tasks

  • Review.

User interface changes

None.

CommentFileSizeAuthor
#16 dom.PNG15.94 KBangel_devoeted
#16 top-bar.PNG21.62 KBangel_devoeted

Issue fork drupal-3621157

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

f0ns created an issue. See original summary.

f0ns’s picture

Issue summary: View changes
f0ns’s picture

edit

f0ns’s picture

Title: Admin theme should override top-bar.html.twig directly instead of adding an unconditional top_bar__gin suggestion » Admin theme should override top-bar.html.twig directly instead of adding an unconditional top_bar__default_admin suggestion
Issue summary: View changes
f0ns’s picture

Status: Active » Needs review
kentr’s picture

f0ns’s picture

@kentr, thanks I was not aware of this [Meta] issue.

kentr’s picture

Status: Needs review » Needs work

Changing it to aside and restoring the h3 is covered by #3583486: Adjust default_admin's top bar to the landmark used with the navigation module, which precedes this issue.

Let's just fix the duplicate template override in this one.

kentr’s picture

f0ns’s picture

My bad, I wasn't aware of #3583486. I removed the landmark changes from the MR and left them to that issue.

This one now only removes the suggestion, renames the template and documents the variables.

f0ns’s picture

Status: Needs work » Needs review
ironnuts’s picture

Re: #12 f0ns can I please confirm that the 3x remaining tasks in the IS have been done? edit: Do you need to update those? Also #9 seems to have limited the scope of this issue. Do you need to update the IS to reflect the reduced scope? This will help me review the issue.

f0ns’s picture

Issue summary: View changes
f0ns’s picture

You are right! My bad, I forgot to update the issue description accordingly.

Fixed that.

angel_devoeted’s picture

StatusFileSize
new21.62 KB
new15.94 KB

Tested MR !17022 on Tugboat and reviewed the code.

I verified in the UI using the Default Admin theme that the top bar renders properly without any layout regressions.
Checked the DOM structure as well. Breadcrumbs, context, and actions render cleanly in their respective regions.
The code changes look solid.

Looks good to me.

top-bar

dom

ironnuts’s picture

+1 to the review by angel_devoeted but there is not test coverage. The general rule is bugs need test coverage. Unless there is a special reason not to?

f0ns’s picture

I don’t see what could be tested / add value based on the commit.

Feel free to explain or help

ironnuts’s picture

Status: Needs review » Reviewed & tested by the community

Thanks f0ns. Ok I will run with that.

kentr’s picture

In cases like this I find tests helpful to confirm that the change doesn't cause a regression. For example, automated versions of the DOM checks that @angel_devoeted did in #16.

Though this may be covered already by the theme's existing tests or #3618216: Add automated tests to Default Admin. In this case I'd say it's up to the maintainers / committers.

ironnuts’s picture

Thank you, kentr. +1.

quietone’s picture

Title: Admin theme should override top-bar.html.twig directly instead of adding an unconditional top_bar__default_admin suggestion » Admin theme should override top-bar.html.twig directly
Issue summary: View changes
Related issues: +#3619804: Remove unused templates from the Admin theme

Checking that the the core gates are passed.

I've updated the title per Title guidelines.

I've moved the Related issues from the Issue Summary to the 'Related issues link' field.

I read the MR, not a code review, and can confirm the add comments are correct. The only question here is if a test is needed, see #20. Manual testing was done in #16.

jurgenhaas’s picture

+1 RTBC

  • catch committed 366e6c38 on 11.5.x
    fix: #3621157 Admin theme should override top-bar.html.twig directly
    
    By...

  • catch committed 56546fc8 on 11.x
    fix: #3621157 Admin theme should override top-bar.html.twig directly
    
    By...

  • catch committed 9e64f885 on 12.0.x
    fix: #3621157 Admin theme should override top-bar.html.twig directly
    
    By...

  • catch committed 096c6ad2 on main
    fix: #3621157 Admin theme should override top-bar.html.twig directly
    
    By...
catch’s picture

Version: main » 11.5.x-dev
Status: Reviewed & tested by the community » Fixed

Nice to get rid of the unnecessary hook implementation. Committed/pushed to main, 12.0.x ,11.x and 11.5.x, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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