Skip to content

Hotkey for focus-on-search broken #2349

@jonbiemond

Description

@jonbiemond

The hotkey, CMD + K, to focus on the search input element, seemingly has no affect on desktop. But works fine on mobile.

Commit e81dd71 adds two search fields to the DOM, one displayed only on mobile.

--- a/djangoproject/templates/includes/header.html
+++ b/djangoproject/templates/includes/header.html
@@ -5,8 +6,11 @@
   <div class="container container--flex--wrap--mobile">
     <a class="logo" href="{% url 'homepage' %}">Django</a>
     <p class="meta">The web framework for perfectionists with deadlines.</p>
-    <div class="mobile-toggle">
-      {% include "includes/toggle_theme.html" %}
+    <div class="header-mobile-only">
+      {% search_form %}
+      <div class="light-dark-mode-toggle">
+        {% include "includes/toggle_theme.html" %}
+      </div>
     </div>
     <button class="menu-button">
       <i class="icon icon-reorder"></i>
@@ -42,6 +46,9 @@
         <li{% if 'fundraising' in request.path %} class="active"{% endif %}>
           <a href="{% url 'fundraising:index' %}">&#9829; Donate</a>
         </li>
+        <li>
+          {% search_form %}
+        </li>
         <li>
           {% include "includes/toggle_theme.html" %}
         </li>

The selector for the search-focus event listener returns the first search input element, and not the element displayed on desktop.

  const el = document.querySelector('#id_q');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions