The search field in the search block does not always use autocomplete="off"
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3466921. --> Reported by: [avpaderno](https://www.drupal.org/user/55077) Related to !42 >>> <p>I was looking at a documentation page on Firefox and I noticed that when I was searching for a function, I got two suggestions: one from Firefox and one from the site.</p> <p><img src="https://www.drupal.org/files/issues/2024-08-08/32279e95ef2fe61ccb3fca1d6f6d2c54.png" alt="screenshot"></p> <p>The dark box is the suggestion from the browser.<br> When I click on a suggestion given from the site, for example <em>DRUPAL_BOOTSTRAP_FULL</em>, the search box is filled with <em>drupal_bootstrap</em>, the suggestion given from Firefox, which is not what I want.</p> <p>Looking at the HTML markup, this is what I see on Firefox.</p> <pre>&lt;input class="api-search-keywords form-autocomplete form-text required ui-autocomplete-input" data-drupal-selector="edit-search" aria-describedby="edit-search--description" data-autocomplete-path="/api/search/autocomplete/11" type="text" id="edit-search" name="search" value="" size="60" maxlength="128" required="required" aria-required="true" data-once="autocomplete"&gt;</pre><p><code>autocomplete="off"</code> is missing, although that does not always happen. (I cannot predict when it is missing.)</p> <p>With Edge, visiting <a href="https://api.drupal.org/api/drupal/includes%21cache-install.inc/class/DrupalFakeCache/7.x">https://api.drupal.org/api/drupal/includes%21cache-install.inc/class/DrupalFakeCache/7.x</a> (the page I was on when I noticed the issue with Firefox), <code>autocomplete="off"</code> is present, but I cannot say sometimes is present and sometimes not, like with Firefox.</p> <p><a href="https://git.drupalcode.org/project/api/-/blob/2.x/src/Form/SearchForm.php?ref_type=heads#L41-51">The code adding the search box in that block</a> is the following one. (Thanks goes to fjgarlin who pointed that out.)</p> <pre>&nbsp;&nbsp;&nbsp; $form['search'] = [<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '#title' =&gt; $this-&gt;t('Function, class, file, topic, etc.'),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '#title_display' =&gt; 'invisible',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '#description' =&gt; $this-&gt;t('Partial match search is supported'),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '#type' =&gt; 'textfield',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '#default_value' =&gt; $query,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '#required' =&gt; TRUE,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '#attributes' =&gt; ['class' =&gt; ['api-search-keywords']],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '#autocomplete_route_name' =&gt; 'api.search.autocomplete',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '#autocomplete_route_parameters' =&gt; ['branch' =&gt; $branch-&gt;id()],<br>&nbsp;&nbsp;&nbsp; ];</pre>
issue