tech-docs-gem icon indicating copy to clipboard operation
tech-docs-gem copied to clipboard

Search results page table of contents is unhelpful

Open lfdebrux opened this issue 4 years ago • 1 comments

For tech docs which do not use the multi-page nav, the table of contents are confusing.

The table of contents as generated by the Middleman extension has two items, 'Search', and 'Results'.

Screenshot of search page for GOV.UK developer docs showing table of contents with 'Search' and 'Results'

However only one of these headings is visible at any one time.

I think having both links visible at the same time is a bit of a strange one. When there are no results, the Results link takes you nowhere, and when there are results, the Search link takes you nowhere. Or rather, it takes you to #how-to-search, but this is within a

that has aria-hidden on it, so presumably the anchor won't resolve for assistive tech users in these cases.  - https://github.com/alphagov/tech-docs-gem/pull/263#pullrequestreview-771229946

Fixing this is a little tricky because of the way the table of contents is generated and inserted:

Ah, this is going to be harder than I thought... the naive way to have an empty sidebar navigation is to override the sidebar content in the core erb template, however for mobile devices this either leaves a table of contents button that does nothing, or omits the search box entirely.

So making this change the proper way would involve massively rewriting the core template, which will take time and be risky. I guess the hacky way to do it would be to do it with JavaScript; this will be slightly easier, but not so great maintenance wise.

... Also, I'm not sure how with JavaScript we could detect whether the page is using a multipage nav or not.  - https://github.com/alphagov/tech-docs-gem/pull/263#issuecomment-934315590.

lfdebrux avatar Oct 06 '21 10:10 lfdebrux

I've done a bit of digging into this following a conversation with @lfdebrux, and I wonder if the simplest and most user-focused solution is to disable search for docs that do not use multipage_nav.

If you set multipage_nav to false, only one page of content is ever displayed (source/index.html.md.erb). So it doesn't seem to make sense to have full search functionality - there's no apparent user need to search a single page (because you can do that with Ctrl+F), and the structure of the results page would be a bit weird and unhelpful.

m-green avatar Nov 24 '21 12:11 m-green