Problem/Motivation

Steps to reproduce

See markup at /admin/help main page block .block-system-main-block

Proposed resolution

Provide plugin ID to theme layer to allow access read plugin ID to use as attribute
Needs discussion/review theme layer because title and description could be read from plugin instance as well

Remaining tasks

- discuss how to pass plugin ID to markup attribute
- patch and test to commit

User interface changes

Sections of /admin/help could be referred via anchors like /admin/help#help-topics

API changes

no

Data model changes

no

Release notes snippet

no

Issue fork drupal-3191278

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

andypost created an issue. See original summary.

andypost’s picture

Status: Active » Needs review
StatusFileSize
new26.37 KB
new6.4 KB

Here's WIP - probably the theme function needs preprocess to populate attributes instead of using plugin methods in template

andypost’s picture

Title: Use plugin id to make help help section headers HTML IDs » Use plugin id to make help section headers HTML IDs
andypost’s picture

Issue tags: +Needs tests

Here's example usage which could be used for test

andypost’s picture

StatusFileSize
new727 bytes
new7.11 KB

The last submitted patch, 2: help-section-id-2.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 5: help-section-id-4.patch, failed testing. View results

andypost’s picture

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

amber himes matz’s picture

I suggest the following:

- filter the plugin id through clean_id, which converts the underscores to hyphens. Underscores are fine in HTML IDs, but the convention in Drupal seems to be hyphens. (The other ids on h2s in admin/help use hyphens.). So,

<h2 id="{{ plugin.getPluginId()|clean_id }}">{{ title }}</h2>

- For better theme dev UX, I agree that adding a preprocess function so that we can use plugin.plugin_id instead of plugin.getPluginId() would be better.

@andypost Thoughts? Do you want me to attempt a patch for you to review? Or would you prefer to do the patch and have me review?

andypost’s picture

Looks good way forward, just not sure "hyphens convention" still active better to ask in slack as I see no much reason to type more when I want to reference an anchor from custom/contrib module

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue tags: -Usabilty +Usability

amber himes matz’s picture

Status: Needs work » Needs review

I took the patch @andypost created and manually made changes to the appropriate files, since hooks have since been moved out of .module files. I also applied my own suggestion to use the clean_id Twig filter to be consistent with the hyphenated HTML ID attribute naming convention and to ensure the plugin ID works as an HTML ID attribute. (That Drupal Twig filter must exist for a reason, right?)

Note: The MR updates template files in 4 locations:

1. The Help module's help-section template (the default template for themes)
2. The Umami installation profile (Classy base theme)
3. Claro admin theme
4. Stable9

So, to thoroughly test, navigate to admin/help and click on any topic. At the top of the page, click the link in the sentence, "See the Help page for more topics" and you should go to /admin/help#help-topics.

On admin/help, inspect the HTML of the section headings (the h2s) and they should all have an ID attribute with the hyphenated name of their help section plugin, e.g. Topics should have an ID of help-topics; Module Overviews should have an ID of "hook-help". ("Getting started" won't have an ID on its H2 as it's not a Help section plugin.)

Do the above inspection for different themes, like Claro and Olivero (I have done this locally). If you want to be super thorough, install Drupal with Umami locally and check out this issue fork. (I have not done this yet.)

amber himes matz’s picture

Issue tags: -Needs tests

Removing "Needs tests" tag because we already have a test for this; it just needed updating.

amber himes matz’s picture

Issue summary: View changes
amber himes matz’s picture

Status: Needs review » Needs work

Looks like more tests need updating, from a quick glance at the failed pipeline.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

amber himes matz’s picture

Status: Needs work » Needs review
Issue tags: +fldc26

I've updated 2 assertions that were looking for h2 headings and were missing the id attribute that we're adding with this MR. Tests are now passing, and this is ready for review.

andypost’s picture

Looks ready except I'd prefer to pass plugin_id to template as it prevents extra function call and could be escaped by twig (maybe clean_id could be skipped

<h2 id="{{ plugin_id()|clean_id }}">{{ title }}</h2>

smustgrave’s picture

Believe there is 1 open thread if someone could answer that.

tobiasb made their first commit to this issue’s fork.

tobiasb’s picture

I replace the usage of plugin with plugin_id.

smustgrave’s picture

@andypost does this still need UX review? My understanding is it's just adding IDs but not chaging the actual headers?

joachim’s picture

Urgh this is going to clash with the conversion of help tests to Kernel tests :(

rkoller’s picture

Usability review

We discussed this issue at #3585350: Drupal Usability Meeting 2026-04-24. That issue will have a link to a recording of the meeting.. The attendees at the usability meeting were @benjifisher, @pallavi singh3013, @rkoller, @simohell, and @worldlinemine.

In general the group agreed on the issue, it is a good thing to add IDs to the headings available on /admin/help - the issue looks good to go.

The only detail to note, those links seem not necessarily directly actionable. First the user has to know that this page has those IDs added to the headings - for most people that fact can go unnoticed. Then users knowing that IDs got added to the headings have to open the devtools to look up the exact ID in question (in particular with small working memories) and then append the link to the current url so they are able to forward the link to someone else. Those anchors are sort of in lack of a touchpoint to the user in the front end.

So the group wondered about something that is totally out of the scope for this issue, but suitable for a followup issue, if it wouldn't be a good thing to make those links more prominent to the user by applying a pattern similar to the one used on Github project pages? There when a heading is getting hovered on or getting into focus a chain icon is getting shown in front of the heading. That way the user is able to right click and copy the URL pointing to that anchor link. That would be a pattern not only useful for the help page but for Core in general (for example on nodes - the odds are high that someone wants to point someone else to a particular section within an article).

If you want more feedback from the usability team, a good way to reach out is in the #ux channel in Slack.

rkoller’s picture

Issue tags: -Needs usability review

forgot to remove the needs usability review tag.

smustgrave’s picture

Should this or #3517299: Convert functional tests in help module to kernel tests be postponed? Would assume #3517299: Convert functional tests in help module to kernel tests since that technically could remain functional.

smustgrave’s picture

Can the remaining tasks section be cleaned up, if discussion is no more we could probably mark this one as it's working.

andypost’s picture

Status: Needs review » Reviewed & tested by the community

let's commiter to decide, I find it ready

joachim’s picture

This is going to horribly break the MR for the test conversion, because that moves files.

alexpott’s picture

@joachim it's 3 test assertions - nothing is going to break horribly and it'll be fine to merge.