The title block should be hidden with the .visually-hidden class so that the H1 element is always on the page.

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

mortona2k created an issue. See original summary.

mortona2k’s picture

Status: Active » Needs review
sagartiwari’s picture

Assigned: Unassigned » sagartiwari

I am reviewing this.

sagartiwari’s picture

Assigned: sagartiwari » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new302.44 KB

I 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!

smustgrave’s picture

Status: Reviewed & tested by the community » Needs work

Think this may need more thought. What if I'm using as a block now I get more H1s on the page.

mortona2k’s picture

@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).

smustgrave’s picture

Need 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.

mortona2k’s picture

I 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.

mlncn’s picture

Based 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?

bwoods’s picture

@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.

butterwise’s picture

StatusFileSize
new875 bytes

Not 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.

butterwise’s picture

StatusFileSize
new1.09 KB

Ugh... the previous patch was no good. This new patch works for me via composer update.