Skip to content

Commit

Permalink
Fixed accessibility issue with search result list
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Jan 14, 2023
1 parent 89a77c5 commit a200e7d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion material/base.html
Expand Up @@ -240,7 +240,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.ba449ae6.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.51d95adb.min.js' | url }}"></script>
{% for path in config.extra_javascript %}
<script src="{{ path | url }}"></script>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion material/partials/search.html
Expand Up @@ -30,7 +30,7 @@
<div class="md-search-result__meta">
{{ lang.t("search.result.initializer") }}
</div>
<ol class="md-search-result__list"></ol>
<ol class="md-search-result__list" role="presentation"></ol>
</div>
</div>
</div>
Expand Down
9 changes: 8 additions & 1 deletion src/assets/javascripts/components/search/result/index.ts
Expand Up @@ -46,7 +46,8 @@ import { translation } from "~/_"
import {
getElement,
getOptionalElement,
watchElementBoundary
watchElementBoundary,
watchToggle
} from "~/browser"
import {
SearchMessage,
Expand Down Expand Up @@ -103,6 +104,12 @@ export function mountSearchResult(
const meta = getElement(":scope > :first-child", el)
const list = getElement(":scope > :last-child", el)

/* Reveal to accessibility tree – see https://bit.ly/3iAA7t8 */
watchToggle("search")
.subscribe(active => list.setAttribute(
"role", active ? "list" : "presentation"
))

/* Update search result metadata */
push$
.pipe(
Expand Down
2 changes: 1 addition & 1 deletion src/partials/search.html
Expand Up @@ -97,7 +97,7 @@
<div class="md-search-result__meta">
{{ lang.t("search.result.initializer") }}
</div>
<ol class="md-search-result__list"></ol>
<ol class="md-search-result__list" role="presentation"></ol>
</div>
</div>
</div>
Expand Down

0 comments on commit a200e7d

Please sign in to comment.