From b874be12de14e2980fc7fde86a9139e5dc1d465e Mon Sep 17 00:00:00 2001 From: Revathyvenugopal162 Date: Mon, 11 Nov 2024 16:11:43 +0100 Subject: [PATCH 1/4] fix: files with names --- .../components/search-button-field.html | 20 +++++++++---------- .../static/css/ast-search.css | 2 +- .../static/js/pydata_search.js | 9 --------- .../ansys_sphinx_theme/static/js/search.js | 2 +- 4 files changed, 12 insertions(+), 21 deletions(-) delete mode 100644 src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/pydata_search.js diff --git a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-button-field.html b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-button-field.html index 32e26e831..eee4e6945 100644 --- a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-button-field.html +++ b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/components/search-button-field.html @@ -1,13 +1,13 @@ diff --git a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/ast-search.css b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/ast-search.css index 8ab9f6ae4..130272e36 100644 --- a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/ast-search.css +++ b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/css/ast-search.css @@ -1,6 +1,6 @@ @import "ansys-sphinx-theme-variable.css"; -.search-results { +.static-search-results { display: flex; flex-direction: column; align-content: stretch; diff --git a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/pydata_search.js b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/pydata_search.js deleted file mode 100644 index 58a326314..000000000 --- a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/pydata_search.js +++ /dev/null @@ -1,9 +0,0 @@ -let searchInput = document.querySelector("form.bd-search input"); -if (searchInput) { - searchInput.focus(); - searchInput.select(); - console.log("[PST]: Set focus on search field."); -} -src = "{{ pathto('_static/searchtools.js', 1) }}"; -src = "{{ pathto('_static/language_data.js', 1) }}"; -src = "{{ pathto('searchindex.js', 1) }}"; diff --git a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/search.js b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/search.js index a01ba7490..536f77c01 100644 --- a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/search.js +++ b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/search.js @@ -1,6 +1,6 @@ const SEARCH_BAR = document.getElementById("search-bar"); const SEARCH_INPUT = SEARCH_BAR.querySelector(".bd-search input.form-control"); -const RESULTS = document.getElementById("search-results"); +const RESULTS = document.getElementById("static-search-results"); const MAIN_PAGE_CONTENT = document.querySelector(".bd-main"); let CURRENT_INDEX = -1; From 0f19cac39681a6f250884a4e0571f948216be399 Mon Sep 17 00:00:00 2001 From: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Date: Mon, 11 Nov 2024 15:21:09 +0000 Subject: [PATCH 2/4] chore: adding changelog file 584.miscellaneous.md [dependabot-skip] --- doc/changelog.d/584.miscellaneous.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/changelog.d/584.miscellaneous.md diff --git a/doc/changelog.d/584.miscellaneous.md b/doc/changelog.d/584.miscellaneous.md new file mode 100644 index 000000000..4bbea430c --- /dev/null +++ b/doc/changelog.d/584.miscellaneous.md @@ -0,0 +1 @@ +fix: enable local page `Search` and default to PyData search on 'Enter' \ No newline at end of file From a910378b50b79d54bda1df3dc8b1ce08d9574e30 Mon Sep 17 00:00:00 2001 From: Revathyvenugopal162 Date: Tue, 12 Nov 2024 11:16:23 +0100 Subject: [PATCH 3/4] fix: offline search --- .../ansys_sphinx_theme/static/js/search.js | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/search.js b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/search.js index 536f77c01..86f0e7bc1 100644 --- a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/search.js +++ b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/search.js @@ -28,12 +28,13 @@ require(["fuse"], function (Fuse) { // Initialize Fuse when the data is fetched function initializeFuse(data, options) { fuse = new Fuse(data, options); + // add env variable "FUSE_ACTIVE" to indicate that the search is ready + document.documentElement.setAttribute("data-fuse_active", "true"); } // Expand the search bar input function expandSearchInput() { RESULTS.style.display = "flex"; - searchingForResultsBanner(); SEARCH_INPUT.classList.add("expanded"); MAIN_PAGE_CONTENT.classList.add("blurred"); SEARCH_INPUT.focus(); @@ -115,7 +116,8 @@ require(["fuse"], function (Fuse) { RESULTS.style.display = "flex"; const warningBanner = document.createElement("div"); warningBanner.className = "warning-banner"; - warningBanner.textContent = "No results found."; + warningBanner.textContent = + "No results found. Press Enter for page search."; warningBanner.style.display = "block"; warningBanner.style.fontStyle = "italic"; RESULTS.appendChild(warningBanner); @@ -187,6 +189,12 @@ require(["fuse"], function (Fuse) { const href = resultItems[CURRENT_INDEX].dataset.href; navigateToHref(href); } + if (resultItems.length > 0) { + event.preventDefault(); // Prevent default enter action + const href = resultItems[0].dataset.href; + navigateToHref(href); + } + break; case "ArrowDown": @@ -205,7 +213,15 @@ require(["fuse"], function (Fuse) { break; default: - searchingForResultsBanner(); + // if environment variable "FUSE_ACTIVE" is set to true + if ( + document.documentElement.getAttribute("data-fuse_active") === "true" + ) { + searchingForResultsBanner(); + } else { + console.error("[AST]: Fuse is not active yet."); + RESULTS.style.display = "none"; + } handleSearchInput(); } } From 99df72e3f83d8491d24695fe2c7fda844d9148f8 Mon Sep 17 00:00:00 2001 From: Revathy Venugopal <104772255+Revathyvenugopal162@users.noreply.github.com> Date: Tue, 12 Nov 2024 15:02:59 +0100 Subject: [PATCH 4/4] fix: no results banner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jorge Martínez <28702884+jorgepiloto@users.noreply.github.com> --- .../theme/ansys_sphinx_theme/static/js/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/search.js b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/search.js index 86f0e7bc1..059f253bd 100644 --- a/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/search.js +++ b/src/ansys_sphinx_theme/theme/ansys_sphinx_theme/static/js/search.js @@ -117,7 +117,7 @@ require(["fuse"], function (Fuse) { const warningBanner = document.createElement("div"); warningBanner.className = "warning-banner"; warningBanner.textContent = - "No results found. Press Enter for page search."; + "No results found. Press Enter for extended search."; warningBanner.style.display = "block"; warningBanner.style.fontStyle = "italic"; RESULTS.appendChild(warningBanner);