diff --git a/ui/src/css/search.css b/ui/src/css/search.css index fe4a37892..0ac3d55e6 100644 --- a/ui/src/css/search.css +++ b/ui/src/css/search.css @@ -48,6 +48,24 @@ margin-top: 0; } +/* the whole result card is one link */ +a.pagefind-modular-list-inner { + display: block; + text-decoration: none; +} + +a.pagefind-modular-list-inner:hover, +a.pagefind-modular-list-inner:focus-visible { + background-color: var(--color-background2); + outline-offset: 2px; +} + +.pagefind-modular-list-title { + color: var(--color-brand-primary); + font-weight: 600; + margin: 0; +} + .pagefind-modular-list-breadcrumbs { font-size: calc(18px * var(--pagefind-ui-scale)); font-weight: 500; diff --git a/ui/src/js/07-search.js b/ui/src/js/07-search.js index 209d84f05..1e79b397b 100644 --- a/ui/src/js/07-search.js +++ b/ui/src/js/07-search.js @@ -5,10 +5,13 @@ document.getElementById('search-background').style.display = 'block' document.getElementById('search').style.display = 'block' - // focus the textbox after popover appears - focusSearchInput() - // add eventlisteners after popover appears - addNavigationToSearch() + // the search assets load on first use (see footer-scripts.hbs) + window.loadSearch().then(function () { + // focus the textbox after the input exists + focusSearchInput() + // add eventlisteners after popover appears + addNavigationToSearch() + }) } function closeSearchPopover () { @@ -37,19 +40,20 @@ } function addNavigationInSearchResults (event) { + // the focused element is the result card link, a direct child of the li if (event.key === 'ArrowDown' && document.activeElement.classList.contains('pagefind-modular-list-link')) { event.preventDefault() // prevent page scrolling - var nextSibling = document.activeElement.parentElement.parentElement.parentElement.nextElementSibling - if (nextSibling) { - nextSibling.querySelector('a').focus() + var nextResult = document.activeElement.closest('li').nextElementSibling + if (nextResult) { + nextResult.querySelector('a').focus() } } if (event.key === 'ArrowUp' && document.activeElement.classList.contains('pagefind-modular-list-link')) { event.preventDefault() // prevent page scrolling - var previousSibling = document.activeElement.parentElement.parentElement.parentElement.previousElementSibling - if (previousSibling) { - previousSibling.querySelector('a').focus() + var previousResult = document.activeElement.closest('li').previousElementSibling + if (previousResult) { + previousResult.querySelector('a').focus() } } } diff --git a/ui/src/partials/article.hbs b/ui/src/partials/article.hbs index ca6899bc7..c52e5ab61 100644 --- a/ui/src/partials/article.hbs +++ b/ui/src/partials/article.hbs @@ -10,7 +10,7 @@ data-pagefind-body > {{! In antora.yml set asciidoc.attributes.page-end-of-life to true/false}} {{#if page.attributes.end-of-life}} -