The search field in the search block does not always use autocomplete="off"

Migrated issue

Reported by: avpaderno

Related to !42 (merged)

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.

screenshot

The dark box is the suggestion from the browser.
When I click on a suggestion given from the site, for example DRUPAL_BOOTSTRAP_FULL, the search box is filled with drupal_bootstrap, the suggestion given from Firefox, which is not what I want.

Looking at the HTML markup, this is what I see on Firefox.

<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">

autocomplete="off" is missing, although that does not always happen. (I cannot predict when it is missing.)

With Edge, visiting https://api.drupal.org/api/drupal/includes%21cache-install.inc/class/DrupalFakeCache/7.x (the page I was on when I noticed the issue with Firefox), autocomplete="off" is present, but I cannot say sometimes is present and sometimes not, like with Firefox.

The code adding the search box in that block is the following one. (Thanks goes to fjgarlin who pointed that out.)

    $form['search'] = [
      '#title' => $this->t('Function, class, file, topic, etc.'),
      '#title_display' => 'invisible',
      '#description' => $this->t('Partial match search is supported'),
      '#type' => 'textfield',
      '#default_value' => $query,
      '#required' => TRUE,
      '#attributes' => ['class' => ['api-search-keywords']],
      '#autocomplete_route_name' => 'api.search.autocomplete',
      '#autocomplete_route_parameters' => ['branch' => $branch->id()],
    ];
Assignee Loading
Time tracking Loading