#7839 Focus on Searchbar

This commit is contained in:
Pieter Lambrecht 2022-03-17 21:33:37 +01:00
parent d53d348da4
commit 5c085758d1
4 changed files with 6 additions and 5 deletions

Binary file not shown.

Binary file not shown.

View File

@ -38,8 +38,8 @@ function initDocument(): void {
function initWindow(): void { function initWindow(): void {
const contentContainer = document.querySelector<HTMLElement>('.content-container'); const contentContainer = document.querySelector<HTMLElement>('.content-container');
if (contentContainer !== null) { if (contentContainer !== null && document.activeElement.tagName.toUpperCase() !== 'INPUT') {
// Focus the content container for accessible navigation. // Focus the content container for accessible navigation, unless an input item has focus
contentContainer.focus(); contentContainer.focus();
} }
} }

View File

@ -5,9 +5,10 @@
aria-label="Search" aria-label="Search"
placeholder="Search" placeholder="Search"
class="form-control" class="form-control"
value="{{ request.GET.q }}" value=""
/> {% if request.GET.q %}autofocus
onfocus="this.value = '{{ request.GET.q }}';" {% endif %}
/>
<input name="obj_type" hidden type="text" class="search-obj-type" /> <input name="obj_type" hidden type="text" class="search-obj-type" />
<span class="input-group-text search-obj-selected">All Objects</span> <span class="input-group-text search-obj-selected">All Objects</span>