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
- Update "empty" markup (SearchController.php line 121). - DONE
- Backport to Stable 9 theme. - DONE
User interface changes
The heading markup.
Before:

After using paragraph tag (not implemented solution):

After using emphasis tag but adding Olivero styling to match the previous style (current implemented solution):

API changes
n/a
Data model changes
n/a
Release notes snippet
(?)
| Comment | File | Size | Author |
|---|---|---|---|
| #40 | search_no_results_after_emphasis.png | 42.68 KB | dmundra |
| #21 | search_no_results_after.png | 40.62 KB | dmundra |
| #21 | search_no_results_before.png | 42.9 KB | dmundra |
Issue fork drupal-3182458
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
alisonIt'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.
Comment #4
alisonLive preview -- with and without search results:
https://mr33-piirchklq1uqlqm1g3vre3muw01gqz6i.tugboat.qa/search/node?key...
https://mr33-piirchklq1uqlqm1g3vre3muw01gqz6i.tugboat.qa/search/node?key...
Comment #5
gauravvvv commentedMoving to RTBC +1, Adding screenshot from live preview.
Comment #6
gauravvvv commentedComment #7
alexpottI'm pretty sure that using a heading here is wrong. I'm guessing the reason
h3is 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"Comment #10
alisonAck, I remember seeing the reply from @alexpott but I definitely forgot to respond!
Great point, absolutely correct.
So the real fix would be to change to a simple
<p>or<div>, optionally with a utility class?Comment #11
alison(FYI: Last GitLab triggered issue comment was because I rebased the target on the MR branch, as prompted by GitLab.)
Comment #12
alisonLive 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!)
Comment #15
smustgrave commentedComment #16
smustgrave commentedSome 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!
Comment #17
gauravvvv commentedComment #20
dmundraI 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.
Comment #21
dmundraComment #22
dmundra@mgifford is the wcag2410 tag appropriate here?
Comment #23
smustgrave commentedReran 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.
Comment #24
mgifford@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.Comment #25
dmundraThanks @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.
Comment #26
lauriiiTagging for FEFM review to figure out how to deal with the markup change.
Comment #27
dmundraMike liked the idea of adding
<em></em>so I pushed up that change and added a screenshot for that.Comment #28
bnjmnmThere'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?Comment #29
dmundraGot 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?Comment #30
smustgrave commentedNot 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!
Comment #31
quietone commentedI 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.
Comment #32
dmundraComment #33
dmundra@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:
Comment #34
dmundraComment #35
smustgrave commentedRemarking and removing issue summary update as is was updated in#32 + #33
Comment #36
quietone commented@dmundra, thank you!
Nothing added to do since my last comment, leaving at RTBC.
Comment #37
lauriiiI changed to using
\Drupal\Core\Render\Element\HtmlTagto 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.
Comment #38
smustgrave commentedThanks for adding those @lauriii, didn't seem to break anything so restoring.
Comment #39
dmundraThanks @lauriii. Great changes!
Comment #40
dmundraUpdated after screenshot in description.
Comment #41
xjmFWIW, 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.
Comment #42
xjmFor fixing the MR situation.
Comment #45
dmundraThank 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.
Comment #47
xjmThanks @dmundra!
Comment #50
nod_Committed 5c8213b and pushed to 11.x. Thanks!