Skip to content

Commit

Permalink
feat: show search
Browse files Browse the repository at this point in the history
  • Loading branch information
thephez committed Oct 8, 2024
1 parent 7e84125 commit 515d9b4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions _static/js/pydata-search-close.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ var hideSearchField = () => {
}
};

function showSearchModal() {
// Remove previous search results
removeResults();

// Focus the search input field
const searchInput = document.querySelector(".search__outer__input");
const modalWrapper = document.querySelector(".search__outer__wrapper");

if (searchInput !== null && modalWrapper !== null) {
searchInput.focus(); // Focus the input field

// Display the search modal
modalWrapper.style.display = "block"; // Show the modal
}
}


/** Add an event listener for hideSearchField() for Escape*/
var addEventListenerForSearchKeyboard = () => {
window.addEventListener(
Expand All @@ -55,6 +72,12 @@ var addEventListenerForSearchKeyboard = () => {
hideSearchField();
}

// Original listener for "/"
if (e.keyCode === 191 && !isModalVisible()) {
e.preventDefault();
showSearchModal();
}

// Open the new search modal by simulating "/" keypress when Ctrl+K is pressed
if (event.ctrlKey && event.key === 'k') {
console.log('ctrl+k was pressed')
Expand Down

0 comments on commit 515d9b4

Please sign in to comment.