Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions lib/rdoc/generator/template/aliki/js/aliki.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,7 @@ function createSearchInstance(input, result) {
}

search.select = function(result) {
let href = result.firstChild.firstChild.href;
const query = this.input.value;
if (query) {
const url = new URL(href, window.location.origin);
url.searchParams.set('q', query);
url.searchParams.set('nav', '0');
href = url.toString();
}
window.location.href = href;
window.location.href = result.firstChild.firstChild.href;
}

search.scrollIntoView = search.scrollInWindow;
Expand All @@ -97,15 +89,27 @@ function hookSearch() {
const search = createSearchInstance(input, result);
if (!search) return;

// Hide search results when clicking outside the search area
document.addEventListener('click', (e) => {
if (!e.target.closest('.navbar-search-desktop')) {
search.hide();
}
});

// Show search results when focusing on input (if there's a query)
input.addEventListener('focus', () => {
if (input.value.trim()) {
search.show();
}
});

// Check for ?q= URL parameter and trigger search automatically
if (typeof URLSearchParams !== 'undefined') {
const urlParams = new URLSearchParams(window.location.search);
const queryParam = urlParams.get('q');
if (queryParam) {
const navParam = urlParams.get('nav');
const autoSelect = navParam !== '0';
input.value = queryParam;
search.search(queryParam, autoSelect);
search.search(queryParam, false);
}
}
}
Expand Down Expand Up @@ -378,9 +382,7 @@ function hookSearchModal() {
if (queryParam && isSmallViewport) {
openSearchModal();
searchInput.value = queryParam;
const navParam = urlParams.get('nav');
const autoSelect = navParam !== '0';
mobileSearch.search(queryParam, autoSelect);
mobileSearch.search(queryParam, false);
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions lib/rdoc/generator/template/aliki/js/search_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,14 @@ SearchController.prototype = Object.assign({}, SearchNavigation, new function()
});
}

this.hide = function() {
this.result.setAttribute('aria-expanded', 'false');
this.setNavigationActive(false);
}

this.show = function() {
this.result.setAttribute('aria-expanded', 'true');
this.setNavigationActive(true);
}
});

2 changes: 1 addition & 1 deletion lib/rdoc/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module RDoc
##
# RDoc version you are using

VERSION = '7.0.1'
VERSION = '7.0.2'
Copy link
Member

Choose a reason for hiding this comment

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

Maybe wrong commit pushed?
I'm fine cutting 7.0.2

Copy link
Member Author

Choose a reason for hiding this comment

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

No I just thought if we could merge the PR we can ship it immediately in 7.0.2 😛
This would still work tho. I'd love to cut a new release right after this is merged.

Copy link
Member

Choose a reason for hiding this comment

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

I see 👍


end