Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation type filtering to search. #1935

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sarahboyce
Copy link
Contributor

@sarahboyce sarahboyce commented Feb 7, 2025

In order to make it easier to refine the search results for the type of information you want, added a filter by docs categories. There are more categories (e.g. "Internals") but I think it is better to only include the most likely categories

This slightly relates to #1628

Mobile view

Search results with new filter - mobile

Desktop view

Search results on desktop with new filter

@sarahboyce sarahboyce force-pushed the doc-type-filtering branch 5 times, most recently from 17aba69 to 8febaf6 Compare February 9, 2025 17:52
@sarahboyce sarahboyce changed the title [WIP] Added documentation type filtering to search. Added documentation type filtering to search. Feb 9, 2025
@sarahboyce sarahboyce marked this pull request as ready for review February 9, 2025 17:55
@sarahboyce sarahboyce requested a review from pauloxnet February 9, 2025 17:56
@sarahboyce sarahboyce force-pushed the doc-type-filtering branch 3 times, most recently from 567f65a to 581467e Compare February 10, 2025 08:06
Copy link
Member

@pauloxnet pauloxnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, but I would try to centralize the list of type in a single dictionary (in search.py) to pass to the template to dynamically build the list of tabs. I would also move the search logic into the manager method by introducing a new search attribute so as to keep all the logic in one place.

docs/views.py Outdated Show resolved Hide resolved
@@ -32,6 +32,13 @@ <h2>{% trans "No search query given" %}</h2>

{% if query %}
<div id="docs-content">
<div role="list" class="tabs">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use the dict of types to dynamically build the list of tabs.

From accessibility point of view, do you think can we use a better semantic HTML tags? I don't know if <nav> can be a better choice, I'm not an a11y expert, but maybe we can ask for help to our @django/accessibility team. It would be great to start moving the website from an old list of <div> or <span> to a more modern semantic website.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated to use <nav> and removed the naming of "tabs" (these aren't real tabs just look a little bit like them). Would love the accessibility team to check this 💯

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, since we're changing the UX a review from a11y point-of-view would be great.

djangoproject/scss/_style.scss Outdated Show resolved Hide resolved
@sarahboyce sarahboyce force-pushed the doc-type-filtering branch 4 times, most recently from 33f19bc to 267865d Compare February 10, 2025 11:05
@@ -11,6 +11,12 @@

{% block body %}
{% if query %}
<nav class="filters" aria-label="{% trans 'Filter results by document type' %}">
Copy link
Contributor Author

@sarahboyce sarahboyce Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have chosen to move this above the number of results title as this is "nicer" for when there are 0 results

e.g.

zero results but has filters available

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense to me. How it looks when there are 0 results in a "tab" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 results in a tab

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I see the screenshot I have a suggestion to improve the message.

In case the search returns 0 results, I would not repeat the name of the section, which is written just above, but rather I would invite repeating the search in all the documentation with a link to perform it directly.

Something like:

<p>0 results for <em>potato</em> in version 5.1</p>

<p>Please try again in <a hrfe="<URL>">all documentation</a>.</p>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea and will push a tweak tomorrow.
My current design doesn't work well with translations but this will work much better 👍

@@ -11,6 +11,12 @@

{% block body %}
{% if query %}
<nav class="filters" aria-label="{% trans 'Filter results by document type' %}">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense to me. How it looks when there are 0 results in a "tab" ?

docs/views.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants