The title block should be hidden with the .visually-hidden class so that the H1 element is always on the page.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | exclude-node-title-3521383-13.patch | 1.09 KB | butterwise |
| #12 | exclude-node-title-3521383-12.patch | 875 bytes | butterwise |
| #5 | class-added.png | 302.44 KB | sagartiwari |
Issue fork exclude_node_title-3521383
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
Comment #3
mortona2k commentedComment #4
sagartiwari commentedI am reviewing this.
Comment #5
sagartiwari commentedI have reviewed the changes from MR #3 and can confirm that the issue is successfully resolved. The title block now uses the .visually-hidden class as expected, ensuring the H1 remains on the page while being hidden visually.
Everything looks good to me!
Comment #6
smustgrave commentedThink this may need more thought. What if I'm using as a block now I get more H1s on the page.
Comment #7
mortona2k commented@smustgrave, can you clarify what you mean?
I think in most cases, the title block is the single H1 on the page, and this is a viable solution for that case. But I'm not sure how to handle any others.
I thought about making a separate module for this, since the use case is so specific (although I think it's by far the most common).
Comment #8
smustgrave commentedNeed to play around with it but I would assume if someone is using this module it's because they are displaying the page title in another way, like a hero banner. Or could using the content type the exclude field is on as a block on another page.
The first scenario I know I've done and this would make multiple H1s appear for a screen reader now. Maybe there needs to be a 2nd checkbox added. So if you check exclude title, a 2nd appears asking if you want to visually hide it, then we do your approach.
Comment #9
mortona2k commentedI see what you mean. However, if I was displaying the page title as an H1 in a separate hero block, I would disable the title block on that page entirely, so only one h1 exists in the html.
There's different ways to set up a page with a hero, but many of them are going to cause a disconnect between where you see the exclude node title checkbox, and where else the title can be displayed (which will take some manual config anyway).
There could be a situation where the hero is a display mode of the current page, placed as a block in a page region. What does the exclude node title option do in this case?
The two step option to choose between hiding and visually hiding could work, but I'm not sure if it covers all the ways we'd want to manage this.
Comment #10
mlncn commentedBased on #3346319: Fix accessibility issues by using visually-hidden on hide and unsetting title element on remove that is the functionality the module has now— `visually-hidden` on Hide, and fully removed for Removed. So this is all set?
Comment #11
bwoods commented@mlncn I'm not using a title block to display the title, but if $build['#access'] is set to false, it's not possible to display the title per the changes in #3346319: Fix accessibility issues by using visually-hidden on hide and unsetting title element on remove. Is the check on isNodeExcluded needed at all? In my scenario, I'm using this patch only to remove $build['#access'] = FALSE, and I can set my titles to be visually-hidden.
Comment #12
butterwise commentedNot to muddy the waters, but the changes in MR #3 also hide the node title on admin pages (edit node, node revisions) where it is desirable. The attached patch adds the visually-hidden class when viewing the node, but not for the admin routes.
Comment #13
butterwise commentedUgh... the previous patch was no good. This new patch works for me via composer update.