Skip to content

Commit

Permalink
Restore the placeholder when search is focused
Browse files Browse the repository at this point in the history
  • Loading branch information
danakj committed Dec 23, 2023
1 parent dc57ecc commit 3abc3a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 7 additions & 0 deletions subdoc/lib/gen/generate_head.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,16 @@ void generate_head(HtmlWriter& html, std::string_view title,
e.preventDefault();
}
};
var searchPlaceholder;
document.querySelector(".search-input").onfocus = (e) => {
searchPlaceholder = e.target.placeholder;
e.target.placeholder = "Type your search here.";
navigateToSearch(e.target.value);
};
document.querySelector(".search-input").onblur = (e) => {
e.target.placeholder = searchPlaceholder;
searchPlaceholder = null;
};
});
// Show or hide any DOM element.
Expand Down
3 changes: 0 additions & 3 deletions subdoc/lib/gen/generate_search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ void generate_search_header(HtmlWriter::OpenMain& main) noexcept {
search_input.add_autocomplete("off");
search_input.add_spellcheck("false");
search_input.add_placeholder("Click or press 'S' to search...");
search_input.add_onblur(
"this.placeholder = 'Click or press \\'S\\' to search...'");
search_input.add_onfocus("this.placeholder = 'Type your search here.'");
}
}

Expand Down

0 comments on commit 3abc3a7

Please sign in to comment.