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

automatically focus in the textbox when you start a search #1426

Merged
merged 10 commits into from
Oct 16, 2024
17 changes: 17 additions & 0 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
<% mobile_logo_path = SiteSetting['MobileLogoPath'] %>
<% sticky_header = user_preference('sticky_header', community: false) == 'true' %>

<script>
const toggleSearchFocus = () => {
const $input = $('#search');

if ($input.is(':focus')) {
$input.blur();
}
else {
$input.focus();
}
};

$(() => {
$('a[data-header-slide="#search-slide"]').on('click', toggleSearchFocus);
});
</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
Loading