Amphtml: amp-autocomplete does request on page load

Created on 7 Aug 2019  路  5Comments  路  Source: ampproject/amphtml

What's the issue?

Loading a page with amp-autocomplete will make a request to the given src without user interaction

How do we reproduce the issue?

The following code will make autocomplete make a request to /suggest without user interaction.

  <form
    method="get"
    target="_top"
    action="/search">
    <amp-autocomplete
      filter="none"
      src="/suggest">
      <input name="q"/>
    </amp-autocomplete>
  </form>

What browsers are affected?

Chrome, not sure about other browsers

Which AMP version is affected?

  • amp V0
  • autocomplete-0.1
  • amp-form-0.1
amp-autocomplete Developer Soon Bug components

All 5 comments

I don't think this violates any of AMP's guarantees or principles. As long as it happens after the component is laid out. What do the other @ampproject/wg-ui-and-a11y folks think?

I think it doesn't violate any of our principles, but it would probably be a nice attribute-gated feature to not fetch until user interaction, or even default behavior. Why do we currently prefetch it?

There are cases when merely focusing the autocomplete displays the currently fetched results (min-characters=0) though it isn't the default.

I can't think of a reason why an initial set of results would be useful if min-characters>0, so I'm fine getting rid of that request.

cc @caroqliu if she's still engaged though. :)

It's prefetched so the user sees a result as soon as they interact

Hmm, I guess I was describing the filter=none case, where we assume the [src] includes the autocomplete value as a parameter.

In that case I can see it being desirable to explicitly remove the first request since it may cause endpoints to calculate a bunch of results based on the empty string, which could cause a lot of server thrash.

Was this page helpful?
0 / 5 - 0 ratings