Skip to content

Commit

Permalink
automatically focus in the textbox when you start a search
Browse files Browse the repository at this point in the history
  • Loading branch information
cellio authored and ArtOfCode- committed Oct 12, 2024
1 parent 9055afd commit 762e27a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
<% mobile_logo_path = SiteSetting['MobileLogoPath'] %>
<% sticky_header = user_preference('sticky_header', community: false) == 'true' %>

<script>
$(document).ready(function () {
$('a[data-header-slide="#search-slide"]').on('click', focusSearch);
});

var search = false;
function focusSearch() {
search = !search;
if (search) {
$('#search').focus();
}
}
</script>

<header class="header is-small has-margin-0<%=' is-dark' if SiteSetting['SiteHeaderIsDark'] %><%= ' sticky' if sticky_header %>">
<div class="container header--container">
<div class="header--brand">
Expand Down

0 comments on commit 762e27a

Please sign in to comment.