Skip to content

Commit

Permalink
Merge pull request #14285 from canonical/wd-14826
Browse files Browse the repository at this point in the history
fix: Show search on search icon click on medium and small screens
  • Loading branch information
akbarkz committed Sep 11, 2024
2 parents 5201d40 + c3ed5e3 commit bf31a09
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
10 changes: 0 additions & 10 deletions static/js/src/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,7 @@ function openSearch(e) {
Array.from(searchButtons).forEach((searchButton) => {
searchButton.setAttribute("aria-pressed", true);
});

addClassesToElements([navigation], ["has-search-open"]);
if (secondaryNav) {
addClassesToElements([secondaryNav], ["u-hide"]);
}
searchInput.focus();
document.addEventListener("keyup", escKeyPressHandler);
}
Expand All @@ -724,13 +720,7 @@ function closeSearch() {
searchButtons.forEach((searchButton) => {
searchButton.removeAttribute("aria-pressed");
});

navigation.classList.remove("has-search-open");

if (secondaryNav) {
secondaryNav.classList.remove("u-hide");
}

document.removeEventListener("keyup", escKeyPressHandler);
}

Expand Down
22 changes: 7 additions & 15 deletions static/sass/_pattern_navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ $meganav-height: 3rem;
font-weight: 400;
}

&.has-search-open .p-navigation__search {
@media (max-width: $breakpoint-navigation-threshold - 1) {
position: fixed;
}
}

.p-navigation__row--25-75 {
@media (min-width: $breakpoint-navigation-threshold - 1) {
.p-navigation__items:first-child {
Expand Down Expand Up @@ -357,19 +363,6 @@ $meganav-height: 3rem;
margin-left: auto;
}
}

.p-search-box__input {
background-color: $color-light !important;

&:focus,
&:hover {
background-color: $color-light !important;
}
}

.p-search-box__input::placeholder {
color: #000;
}
}

.p-navigation__banner {
Expand Down Expand Up @@ -419,11 +412,10 @@ $meganav-height: 3rem;

.p-navigation__search {
align-items: center;
background-color: #262626;
display: flex;
justify-content: center;
left: 0;
padding: 1rem;
padding: 0.6rem 5rem 0.6rem 0;
position: absolute;
top: 2rem;
width: 100%;
Expand Down

0 comments on commit bf31a09

Please sign in to comment.