Skip to content

Commit

Permalink
release: Bump version 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Revathyvenugopal162 committed Nov 13, 2024
1 parent afba4dd commit ad3afd4
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 25 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/584.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: enable local page `Search` and default to PyData search on 'Enter'
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
[project]
# Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections
name = "ansys-sphinx-theme"
version = "1.2.0"
version = "1.2.1"
description = "A theme devised by ANSYS, Inc. for Sphinx documentation."
readme = "README.rst"
requires-python = ">=3.10,<4"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

<div class="search-bar pst-js-only" id="search-bar">
<form class="bd-search d-flex align-items-center" action="{{ pathto('search') }}" method="get">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="search" class="form-control" name="q" placeholder="{{ theme_search_bar_text }}"
aria-label="{{ theme_search_bar_text }}" autocomplete="off" autocorrect="off"
autocapitalize="off" spellcheck="false"/>
<span class="search-button__kbd-shortcut">
<kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd>
</span>
</form>
<div id="search-results" class="search-results" style="display: none;" tabindex="0"></div>
<form class="bd-search d-flex align-items-center" action="{{ pathto('search') }}" method="get">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="search" class="form-control" name="q" placeholder="{{ theme_search_bar_text }}"
aria-label="{{ theme_search_bar_text }}" autocomplete="off" autocorrect="off"
autocapitalize="off" spellcheck="false" />
<span class="search-button__kbd-shortcut">
<kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd>
</span>
</form>
<div id="static-search-results" class="static-search-results" style="display:none;" tabindex="0"></div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@import "ansys-sphinx-theme-variable.css";

.search-results {
.static-search-results {
display: flex;
flex-direction: column;
align-content: stretch;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 extended search.";
warningBanner.style.display = "block";
warningBanner.style.fontStyle = "italic";
RESULTS.appendChild(warningBanner);
Expand Down Expand Up @@ -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":
Expand All @@ -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();
}
}
Expand Down

0 comments on commit ad3afd4

Please sign in to comment.