Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves #2739 Use "/" to focus search input in the Header #2770

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ocamlorg_frontend/components/forms.eml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let search_input ?button_attrs ?input_attrs ?dropdown_html ~label ~name _class =
type="search"
name="<%s name %>"
placeholder="<%s label %>"
@keydown.escape="$event.target.blur()"
class="bg-white dark:bg-dark-card text-title dark:text-dark-title h-full w-full font-normal focus:border-primary dark:focus:border-dark-primary focus:ring-0 border-primary dark:border-dark-primary rounded-md rounded-r-none px-3 py-1 placeholder-text-content dark:placeholder:text-dark-content appearance-none focus:outline-none"
<%s! Option.value ~default:"" input_attrs %>
>
Expand Down
1 change: 1 addition & 0 deletions src/ocamlorg_frontend/components/header.eml
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,4 @@ in
</ul>
</nav>
</header>
<%s! Search.script %>
13 changes: 12 additions & 1 deletion src/ocamlorg_frontend/components/search.eml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,15 @@ let display_surrounding_text ~search (text : string) =
^ render_item (shorten_from_middle ~length:100) a
^ render_item (shorten_from_right ~length:100) b
| [] -> shorten_from_right ~length:200 text
else shorten_from_right ~length:200 text
else shorten_from_right ~length:200 text


let script =
<script>
window.addEventListener('keydown', function(event) {
if (event.key === "/") {
event.preventDefault();
document.querySelector("input[type='search']").focus()
}
})
</script>
Loading