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><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"></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> $form['search'] = [<br> '#title' => $this->t('Function, class, file, topic, etc.'),<br> '#title_display' => 'invisible',<br> '#description' => $this->t('Partial match search is supported'),<br> '#type' => 'textfield',<br> '#default_value' => $query,<br> '#required' => TRUE,<br> '#attributes' => ['class' => ['api-search-keywords']],<br> '#autocomplete_route_name' => 'api.search.autocomplete',<br> '#autocomplete_route_parameters' => ['branch' => $branch->id()],<br> ];</pre>
issue