Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The $secondary_links defaults to using the User menu's links in D7. But Drupal core still defaults to using "Secondary menu" as the accessible heading for those links. This is completely inaccurate. So much for accessibility!
The best solution I can think of is to query for the actual menu used for the $secondary_links and use that menu's title as the heading.
Task | Novice task? | Contributor instructions | Complete? |
---|---|---|---|
Reroll the patch if it no longer applies. | Instructions | ||
Add automated tests | Instructions | ||
Manually test the patch | Novice | Instructions | |
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards | Instructions |
Comment | File | Size | Author |
---|---|---|---|
#97 | Screen Shot 2014-09-28 at 8.43.20 AM.png | 96.61 KB | mgifford |
#95 | drupal-secondary-links-1079010-95.patch | 1.41 KB | BarisW |
#93 | drupal-secondary-links-1079010-93.patch | 1.37 KB | BarisW |
#89 | drupal-secondary-links-1079010-89.patch | 1016 bytes | pgautam |
#75 | Secondary-Menu-After.png | 147.2 KB | mgifford |
Comments
Comment #1
Everett Zufelt CreditAttribution: Everett Zufelt commentedI think you're right. Please, please, I'm hoping that all menus will be blocks in D8 and we can get rid of these.
Comment #2
JohnAlbinAgreed. All menus as blocks in D8 will be a big improvement.
Ok. Fixed in Zen. http://drupalcode.org/project/zen.git/commit/551c313
Comment #3
JohnAlbinMoving to core.
I'm working on this issue over in http://drupalcode.org/sandbox/johnalbin/1074382.git/shortlog/refs/heads/...
Here's the patch. I'm not 100% certain this text is translatable. I admit to not understanding how you are supposed to translate text that is input into admin forms and stored in the database.
t()
is problematic, apparently?Comment #5
bowersox CreditAttribution: bowersox commented+1. I support this title change. The patch had some unrelated .htaccess changes, but otherwise the approach looks good.
Regarding translation, my philosophy is that user-provided content is not subject to translation with t(). We simply output user-entered content in the language in which it was entered. Right?
Comment #6
mgiffordHope this patch passes the bot. I edited it to cut out the .htaccess info so hopefully it applies.
Comment #7
yoroy CreditAttribution: yoroy commentedbot?
Comment #9
mgiffordThanks for prodding the bot yoroy. Hopefully this works better this time.
Comment #11
Everett Zufelt CreditAttribution: Everett Zufelt commentedMarked #878772: Primary and Secondary links headings are hard coded as duplicate, as this issue has some code.
Issue summary from #878772: Primary and Secondary links headings are hard coded:
And comment from David_Rothstein
Comment #12
Maksym Kozub CreditAttribution: Maksym Kozub commentedDo you (and David) mean the title of a source menu from which those links are taken, or do you mean something else? There are titles at least in Stark, and those titles are (hard-coded) "Main menu" and "Secondary menu".
Comment #13
sunRelated: #945654: Default menus have hardcoded titles which cannot be edited
Comment #14
mgiffordRe-rolling the patch.
Comment #16
mgifford#14: 1079010-secondary-menu-heading-13.patch queued for re-testing.
Comment #18
Albert Volkman CreditAttribution: Albert Volkman commentedRe-roll.
Comment #20
droplet CreditAttribution: droplet commentedComment #22
droplet CreditAttribution: droplet commentedComment #24
droplet CreditAttribution: droplet commented#22: secondary_heading.patch queued for re-testing.
Comment #26
droplet CreditAttribution: droplet commentedfix search module tests
Comment #27
mgifford#26: secondary_heading.patch queued for re-testing.
Comment #29
Albert Volkman CreditAttribution: Albert Volkman commentedRe-roll to account for template location change.
Comment #30
mgiffordtagging.
Comment #31
mgifford#29: secondary_menu_heading-1079010-29.patch queued for re-testing.
Comment #33
mparker17Hmm... looks like the
user-menu
menu has been renamed toaccount
.Also fixing a missing space.
Re-rolling.
Comment #34
mgifford#33: secondary_links_heading-1079010-33.patch queued for re-testing.
Comment #35
mgiffordLooks good. It's finally showing the proper menu:
<h2 class="element-invisible">User account menu</h2>
Comment #36
sunI think we should close this issue as won't fix or duplicate of #1869476: Convert global menus (primary links, secondary links) into blocks - which apparently removes this custom primary/secondary menu links markup generation entirely.
Comment #37
David_Rothstein CreditAttribution: David_Rothstein commentedAlso, I think the issue I raised that is linked to in #11 is still relevant here; why should we start exposing a potentially admin-facing menu name to end users of the site?
The only extra information that a sighted user has here which a screen reader user does not is that the visual cues on the page indicate this menu is of secondary importance in the navigation structure.... they do not have any information about the stored title. Therefore, I still think "Secondary X" should always be an appropriate screen reader label for it. (As mentioned earlier, though, "menu" may not really be an appropriate word for the X.)
Comment #38
mgiffordI'm not opposed to that. However, what happens if that patch doesn't get in?
Comment #39
droplet CreditAttribution: droplet commentedComment #40
mgifford#33: secondary_links_heading-1079010-33.patch queued for re-testing.
Comment #41
mgifford#33: secondary_links_heading-1079010-33.patch queued for re-testing.
Comment #42
mparker17#33: secondary_links_heading-1079010-33.patch queued for re-testing.
Comment #44
mgiffordOk, this needs to be re-written in twig now.
What happens to the code in core/includes/theme.inc
Gotta wrap my head around this new templating system.
Comment #45
mparker17The old patch did not apply anymore so I don't have an interdiff.
Here are some notable changes:
core/modules/block/tests/themes/block_test_theme/block_test_theme.info.yml
, but it doesn't seem to exist anymore? Certainly it doesn't have it's own template file.SearchConfigSettingsFormTest
doesn't need to be changed anymore.theme('links'...
function previously in the page templates is now done at the bottom oftemplate_preprocess_page()
, so no changes needed to be made to the page template files.I've manually tested this patch by changing which menu is currently selected as the "secondary menu" at
admin/structure/menu/settings
and changing the name of the currently-selected secondary menu, and confirmed that the markup changes correctly.I did not see an automated test in the previous patch for this feature: does anyone know if there is one? I can add one if not.
Comment #46
mparker17Whoops.
Comment #47
mparker17Rats, had unstaged changes. The patch from #45 probably won't work; but the notes there are still valid. Try again.
Comment #49
mparker17#47: secondary_links_heading-1079010-47.patch queued for re-testing.
Comment #51
mparker17The secondary links heading shouldn't affect the search config form or unmanaged remote file deletion. Let's try this again.
Comment #52
mparker17#47: secondary_links_heading-1079010-47.patch queued for re-testing.
Comment #54
mgifford#47: secondary_links_heading-1079010-47.patch queued for re-testing.
Comment #56
mgiffordJust an update from #47.
Comment #58
dcrocks CreditAttribution: dcrocks commented#56: secondary_links_heading-1079010-56.patch queued for re-testing.
Comment #60
mgiffordRe-rolled.. Although I also nested the code within an existing if statement since that's the only place it seems to be used. Should help performance.
Comment #61
mgiffordIt should all be within
if (!empty($variables['secondary_menu'])) {
now.Comment #64
mgiffordre-roll.
Comment #65
mgiffordComment #67
heddnComment #68
LinL CreditAttribution: LinL commentedComment #69
droplet CreditAttribution: droplet commentedComment #70
Jalandhar CreditAttribution: Jalandhar commentedComment #71
Jalandhar CreditAttribution: Jalandhar commentedComment #72
mgifford@Jalandhar Drat.. I was hoping you'd get to fixing the tests. What stopped you from producing a new patch?
Comment #73
Jalandhar CreditAttribution: Jalandhar commented@mgifford : Actually, I was not sure about few things in the failing tests and more over I was working on other tickets. Unassigned so that someone else can pick this up in the meanwhile
Comment #74
er.pushpinderrana CreditAttribution: er.pushpinderrana commentedChecked for active menu for current page in this patch.
Comment #75
mgiffordOk, so I can see that with the patch the 2ndary menu is looking better.
But when I change the name of the menu to something other than "User account menu" it still comes out as:
<h2 id="links__system_secondary_menu" class="visually-hidden">User account menu</h2>
I really don't think this is related to this patch, but wanted to flag it as a concern before marking it RTBC.
Comment #76
cilefen CreditAttribution: cilefen commentedComment #77
cilefen CreditAttribution: cilefen commentedComment #80
Jalandhar CreditAttribution: Jalandhar commentedPatch #74, no longer applies.
Here is the update for the patch.
Comment #81
Jalandhar CreditAttribution: Jalandhar commentedComment #83
Jalandhar CreditAttribution: Jalandhar commentedAnother try at the patch.
Comment #85
cilefen CreditAttribution: cilefen commentedmodule_exists() is deprecated.
Comment #88
mgiffordNo longer seems to apply.
Comment #89
pgautam CreditAttribution: pgautam commentedRerolled patch.
Comment #90
mgiffordI completely changed the menu here:
http://sfe2853d5ccc8e91.s2.simplytest.me/
In admin/structure/menu/settings I set a different menu to be the Source for the Secondary links.
After clearing cache I still have the User account menu header
<h2 id="links__system_secondary_menu" class="visually-hidden">User account menu</h2>
even when it's for the footer menu.Similar problem as in #75 when you change the name of the menu to something other than "User account menu" it doesn't show up in the header.
Comment #91
mgiffordComment #92
BarisW CreditAttribution: BarisW commentedFixed it locally, will add a patch tomorrow.
Comment #93
BarisW CreditAttribution: BarisW commentedThis should nail it. While at it, I found out that this goes wrong for primary links too. The use case is limited, but one is able to change the source of the main menu. Then, the heading should reflect this too, just as with the secondary links. This patch fixes both.
Comment #95
BarisW CreditAttribution: BarisW commentedIt now uses the site config, so the labels are translatable too.
Comment #96
BarisW CreditAttribution: BarisW commentedComment #97
mgiffordThis looks great. It now follows the value of the secondary menu! Tested this on SimplyTest.me.
Comment #98
lokapujyaThe comment in #37 seems legit. Sounds like the hardcoded name is actually the more useful label.
Comment #99
mgifford@lokapujya - Right now you can edit the "Main navigation" text so that an administrator could provide different information to a screen reader user through the UI. This isn't possible at the moment for the "Secondary navigation".
It is possible that "Secondary navigation" is more descriptive than the actual name of the menu, but since you can't change it now without adjusting the theme, it's kinda limiting.
@David_Rothstein's always got interesting/useful comments and #37 is no exception.
"why should we start exposing a potentially admin-facing menu name to end users of the site?"
The Main menu name is editable (as a block), so this isn't really new.
"The only extra information that a sighted user has here which a screen reader user does not is that the visual cues on the page indicate this menu is of secondary importance in the navigation structure"
Adding the name of the menu is more semantic. Adding more queues than are available to sighted users shouldn't be seen as a problem.
Comment #100
mgiffordJust looking at #36 actually where @sun suggests this might not be needed due to #1869476: Convert global menus (primary links, secondary links) into blocks. And indeed it is!
Both menu headings can be edited now without this patch. Thanks everyone for their work on this patch.
Comment #101
mgifford