Problem/Motivation

When there are no search results, the markup of the "empty" message is h3, but there's no h2. Best practice is to not skip heading levels (WCAG success criteria 1.3.1, "Organizing a page using headings" advisory technique).

EDIT: More importantly, as pointed out in the thread, this heading doesn't head any content -- the heading is used to make the text look a certain way:

https://www.w3.org/WAI/WCAG21/Techniques/failures/F43 - either "Example 1: A heading used only for visual effect" OR "Example 2: Using heading elements for presentational effect"

Steps to reproduce

On a Drupal site with default/core search, run a search that yields no results, i.e. "asdfgghjhasdfj"--
/search/node?keys=asdfgghjhasdfj

On the resulting page, you'll see the following markup:
<h3>Your search yielded no results.</h3>

Proposed resolution

Replace the heading markup with a simple <p> or <div> element -- perhaps with a class if styling is desired, but that would be optional.

Remaining tasks

  1. Update "empty" markup (SearchController.php line 121). - DONE
  2. Backport to Stable 9 theme. - DONE

User interface changes

The heading markup.

Before:
Screenshot of empty search results message with header styling

After using paragraph tag (not implemented solution):
Screenshot of empty search results message with paragraph styling

After using emphasis tag but adding Olivero styling to match the previous style (current implemented solution):
Screenshot of empty search results message with emphasis tag and default olivero styling

API changes

n/a

Data model changes

n/a

Release notes snippet

(?)

Issue fork drupal-3182458

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

alisonjo315 created an issue. See original summary.

alison’s picture

It's my first Drupal-GitLab-issue_fork-merge_request -- I used what seems to be the intended documentation?? -- anyway, I hope I did it right, but please be gentle if I did it wrong :D

I'll be happy to amend/redo/fix whatever, just let me know.

alison’s picture

gauravvvv’s picture

StatusFileSize
new41.66 KB

Moving to RTBC +1, Adding screenshot from live preview.

gauravvvv’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work

I'm pretty sure that using a heading here is wrong. I'm guessing the reason h3 is that someone like the look of it. But this is not a heading. It doesn't head any content. A heading element implies a structure that is not present. Looking at https://www.w3.org/WAI/WCAG21/Techniques/failures/F43 - I think we're guilty of either "Example 1: A heading used only for visual effect" OR "Example 2: Using heading elements for presentational effect"

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.

alison’s picture

Version: 9.4.x-dev » 9.3.x-dev
Issue summary: View changes

Ack, I remember seeing the reply from @alexpott but I definitely forgot to respond!

I'm pretty sure that using a heading here is wrong. I'm guessing the reason h3 is that someone like the look of it. But this is not a heading. It doesn't head any content. A heading element implies a structure that is not present. Looking at https://www.w3.org/WAI/WCAG21/Techniques/failures/F43 - I think we're guilty of either "Example 1: A heading used only for visual effect" OR "Example 2: Using heading elements for presentational effect"

Great point, absolutely correct.

So the real fix would be to change to a simple <p> or <div>, optionally with a utility class?

alison’s picture

(FYI: Last GitLab triggered issue comment was because I rebased the target on the MR branch, as prompted by GitLab.)

alison’s picture

Status: Needs work » Needs review

Live preview -- with and without search results:
With results: https://mr33-piirchklq1uqlqm1g3vre3muw01gqz6i.tugboat.qa/search/node?key...
Without results: https://mr33-piirchklq1uqlqm1g3vre3muw01gqz6i.tugboat.qa/search/node?key...

(Apologies for the extra notifications!)

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

smustgrave’s picture

Issue tags: +Needs usability review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs accessibility review, +Needs Review Queue Initiative, +Needs screenshots

Some more background I believe the violation being reported is a AAA issues where the heading structure should follow

H1
- H2
--H3

Currently is

H1
-H3

Moving to NW

Since this changes the UI though I think a class or something should be added to add some of the styling back. Would see if olivero already has one.

Also will need before/after screenshots added to the issue summary under user interface section as this potentially changes the UI.

Thanks!

gauravvvv’s picture

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

dmundra’s picture

Version: 9.5.x-dev » 11.x-dev
Issue tags: +wcag2410

I created a new merge request targeting 11.x branch. Added wcag2410 tag. I will add screenshots next.

I couldn't find a class in Oliverio to use and I am not sure one is needed. If we made the styling look like a header again it could be confusing.

dmundra’s picture

Issue summary: View changes
StatusFileSize
new42.9 KB
new40.62 KB
dmundra’s picture

Status: Needs work » Needs review

@mgifford is the wcag2410 tag appropriate here?

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs screenshots

Reran the tests and seems the issue before was random.

Tested using the https://www.ssa.gov/accessibility/andi/help/install.html tool
And on the search page the heading structure goes

h1 - Search for xyz
Nothing in the body now
h2 first item in footer.

Since this text isn't signifying a "structure" of the page I think the change is fine.

mgifford’s picture

Issue tags: -wcag2410 +wcag131

@dmundra - I think it could be SC 2.4.10 but keep in mind that that's a triple-A criteria that "covers sections within writing, not user interface components". And I'd argue that this is part of the user interface.

Looking at https://www.w3.org/TR/WCAG20-TECHS/G141 I think it would be better to put it under SC 1.3.1.

But then it may be more of a best practice anyways https://govtnz.github.io/web-a11y-guidance/wct/headings/make-headings-ac...

I wondered if we could enlarge "Your search yielded no results" rather than just leaving it in the <p></p> tag. I liked that it stood out more visually in what would otherwise be a pretty blank page. This is an important message for folks to see, even if semantically it shouldn't be a heading.

dmundra’s picture

Thanks @smustgrave and @mgifford.

Mike, I figured that 1.3.1 might be a better criteria and thanks for updating that.

I am not sure about enlarging that text and I don't see any similar examples of that in Drupal. One that I can find is on the home page 'You haven’t created any frontpage content yet.' uses <em></em> tag, so maybe that would be option.

One interesting idea is maybe adding 'no results' to the header or another way for the message to stand out. Maybe we can get input from UX folks.

lauriii’s picture

Tagging for FEFM review to figure out how to deal with the markup change.

dmundra’s picture

Issue summary: View changes
StatusFileSize
new40.49 KB

Mike liked the idea of adding <em></em> so I pushed up that change and added a screenshot for that.

bnjmnm’s picture

Status: Reviewed & tested by the community » Needs work

There's a tricky issue here: because the <h3> is added in a controller and not a template, so this markup change is not protected by the Stable 9 theme, yet is exactly the type of change Stable protects against. While it's clearly an accessibility improvement, it's also something that could cause an unexpected regression in a public part of an existing site.

If there is a way to preserve the <h3> for themes based from Stable 9, then this would be fine. I'm not sure a controller override is an option, but perhaps some JS or Twig cleverness could take care of it?

dmundra’s picture

Status: Needs work » Needs review

Got it @bnjmnm. I found that the search results does have a hook hook_preprocess_item_list__search_results. I pushed up a commit that adds the stable9.theme file which calls that hook to reset the markup. Would that be an acceptable solution?

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Not 100% sure about adding a .theme file now but don't see any other way.

Think the use case is there for adding it but guess since we didn't have one before not sure if it's something purposely been avoid. But lets see!

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

I read the issue summary. The proposed resolution is a choice between two options. Which one is implemented here? There are screenshots as well but they are examples of the options being consider.

I then read the comments. It is good to see discussion about how to solve this. The last suggestion was in #28. Has that solution been implemented or something else?

So, since issue summaries matter I am tagging this for an issue summary update and setting to NW.

dmundra’s picture

Issue summary: View changes
dmundra’s picture

Issue summary: View changes

@quietone, I updated the summary (marked the tasks DONE and commented on which solution was implemented). Is that a good update to the summary?

Summary here:

  • Implemented the emphasis solution.
  • Added code to backport change for Stable 9 theme.
dmundra’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs issue summary update

Remarking and removing issue summary update as is was updated in#32 + #33

quietone’s picture

@dmundra, thank you!

Nothing added to do since my last comment, leaving at RTBC.

lauriii’s picture

Status: Reviewed & tested by the community » Needs review

I changed to using \Drupal\Core\Render\Element\HtmlTag to provide themes with more flexibility to override this.

I think it's a good call to add BC for this in Stable because both Olivero and Umami had regressions as a result of this. I tried to address those.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for adding those @lauriii, didn't seem to break anything so restoring.

dmundra’s picture

Thanks @lauriii. Great changes!

dmundra’s picture

Issue summary: View changes
StatusFileSize
new42.68 KB

Updated after screenshot in description.

xjm’s picture

FWIW, accessibility bugs are listed as one of the very few reasons we will make changes to Stable or Classy within a release, I think that's appropriate too. I'll leave it to them to remove the tag though if/when they sign off on both plan and code. :)

Meanwhile, there are three different issue fork branches, two with MRs and one without. Which is canonical? Please close the non-canonical MRs. (If the non-MR one should be closed, you have to first open an MR and then close it again to get it out of the IS UI.

xjm’s picture

Status: Reviewed & tested by the community » Needs review

For fixing the MR situation.

dmundra’s picture

Thank you @xjm. I open and closed the fork branch that had to no MR. This one https://git.drupalcode.org/project/drupal/-/merge_requests/33 I do not have the option to close it, but it can be closed.

xjm’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @dmundra!

  • nod_ committed 5c8213b5 on 11.x
    Issue #3182458 by alison, dmundra, lauriii, xjm, Gauravvvv, smustgrave,...

  • nod_ committed 57352211 on 10.2.x
    Issue #3182458 by alison, dmundra, lauriii, xjm, Gauravvvv, smustgrave,...
nod_’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs frontend framework manager review

Committed 5c8213b and pushed to 11.x. Thanks!

Status: Fixed » Closed (fixed)

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