Skip to content

Commit

Permalink
Fix errors on search page
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Sep 20, 2023
1 parent aee35dc commit d23503f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
3 changes: 1 addition & 2 deletions assets/css/search.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
#search .loading {
height: 64px;
width: 64px;
vertical-align: middle;
position: absolute;
top: 50%;
left: calc(18%);
left: calc(50% - 32px);
}

#search .loading div {
Expand Down
6 changes: 5 additions & 1 deletion assets/js/sidebar/sidebar-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ function markActiveSidebarTab (activeType) {

function scrollNodeListToCurrentCategory () {
const nodeList = qs(sidebarNodeListSelector(getCurrentPageSidebarType()))
if (!nodeList) { return }

const currentPage = nodeList.querySelector('li.current-page')
if (currentPage) {
currentPage.scrollIntoView()
Expand All @@ -156,6 +158,7 @@ function markCurrentHashInSidebar () {
const nodes = sidebarNodes[getCurrentPageSidebarType()] || []
const category = findSidebarCategory(nodes, hash)
const nodeList = qs(sidebarNodeListSelector(getCurrentPageSidebarType()))
if (!nodeList) { return }

const categoryEl = nodeList.querySelector(`li.current-page a.expand[href$="#${category}"]`)
if (categoryEl) {
Expand Down Expand Up @@ -219,11 +222,12 @@ function addEventListeners () {
// Keep .current-hash item in sync with the hash, regardless how the change takes place
window.addEventListener('hashchange', event => {
const nodeList = qs(sidebarNodeListSelector(getCurrentPageSidebarType()))
if (!nodeList) { return }

const currentListItem = nodeList.querySelector('li.current-page li.current-hash')
if (currentListItem) {
clearCurrentHashElement(currentListItem)
}

markCurrentHashInSidebar()
})
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit d23503f

Please sign in to comment.