Ticket #7032 (closed feature: fixed)

Opened 3 years ago

Last modified 3 years ago

Autocomplete: Add option to automatically highlight the first result

Reported by: dziastinux Owned by:
Priority: blocker Milestone: 1.8.11
Component: ui.autocomplete Version: 1.8.9
Keywords: Cc:
Blocking: Blocked by:

Description (last modified by scott.gonzalez) (diff)

I have no privilege to reopen #5674, so I am creating new ticket.

Quick and dirty example:  http://jsfiddle.net/Kgx3J/32/show/ Type 'a' to see suggestions. It can be done even better, no need to brake anything :)


Adding notes since there are lots of comments and these are important:

  • The option should be named autoFocus
  • We have to track down the race condition described in  the extension

Change History

comment:1 Changed 3 years ago by dziastinux

comment:2 Changed 3 years ago by scott.gonzalez

  • Type changed from bug to feature

This actually does create a significant change in behavior. Typing "a" followed by tab or enter has very different behavior than existing releases.

comment:3 Changed 3 years ago by dziastinux

Tab and Enter suppose to select currently active item (it still works in my example) so I can't see significant change in behavior.

P.s. It is possible that 'selectFirst' primary use case is to force user to select item from the list.

comment:4 Changed 3 years ago by scott.gonzalez

Yes, tab and enter act as you expect, but this is a change in behavior from existing releases. It was previously easy to type any value you want, ignoring the suggestions. The autocomplete is passive in existing releases and this change would make it aggressive in the sense that you have to explicitly opt-out of selecting a value.

comment:5 Changed 3 years ago by dziastinux

Not exactly true. You selectFirst still allows to enter custom value, but now there are two cases:

  1. User wants to enter sub-part of suggestion;
  2. User wants to enter completely different value (from all the suggestions).

In 1st case user has two options: select one of the suggestions or press Esc and enter custom value.
In 2nd case user feels no discomfort (as soon as no items are matched autocomplete menu is closed and further behavior is identical to v1.8.9).

What have I missed?

Last edited 3 years ago by dziastinux (previous) (diff)

comment:6 Changed 3 years ago by scott.gonzalez

What I'm saying is that case 1 is a significant change in the behavior.

comment:7 Changed 3 years ago by dziastinux

For user - yes. But that is the reason why it should be an option (developer decides whether to enable or not).

P.s. HTML options tag selects first item by default (no way to unselect). So users are used to it.

comment:8 Changed 3 years ago by scott.gonzalez

Why is the existing extension not suitable?

comment:9 Changed 3 years ago by dziastinux

I am just saying that it wouldn't be to complicate to implement this option.

comment:10 Changed 3 years ago by scott.gonzalez

  • Status changed from new to closed
  • Resolution set to wontfix

Just because it's easy to implement something doesn't mean it should be in the core of the plugin. Autocomplete would easily have 30 options if we implemented all of the small features. The team's view on this is still that it is not common enough to add this option. If the extension becomes popular enough, we can add it to the official plugin.

comment:11 Changed 3 years ago by dziastinux

No offense but it looks that you are doing your best to postpone/avoid implementing this feature no matter the reason.

Still it would be nice to have this feature in the autocomplete demo (let's say, combined with existing combobox demo). Am I asking too much?

Last edited 3 years ago by dziastinux (previous) (diff)

comment:12 Changed 3 years ago by scott.gonzalez

The only reason features are added are: 1) they become popular, 2) they are needed in order for users to build some other feature.

Adding a demo doesn't address your issue of wanting this built-in. In fact, the existing extension servers your actual needs better since an official demo would implement the functionality as a one-off implementation, not as a new option.

Last edited 3 years ago by scott.gonzalez (previous) (diff)

comment:13 Changed 3 years ago by akantro

First of all.

  1. This was the existing behavior of the  autocomplete plugin that this plugin is "trying" to decomission.
  2. This option "selectFirst" is in the old plugin and is in the behavior in most every other autocomplete plugin (fcbkcomplete, etc) and mimics the experience you get in a)  facebook dropdown autocompletes, b) autocomplete (for tags) which represents about 550 Million people so i would argue that this constitute "popular"
  3. This allows the user experience to be much quicker as you can start entering a value and just click enter and then start typing the next entry (in multiple mode). Again refer to facebook or stackoverflow for example of usage.
Last edited 3 years ago by akantro (previous) (diff)

comment:14 Changed 3 years ago by scott.gonzalez

  • Priority changed from minor to blocker
  • Status changed from closed to reopened
  • Summary changed from Select first item when list opens to Autocomplete: Add option to automatically highlight the first result
  • Resolution wontfix deleted
  • Milestone changed from 1.9 to 1.8.11

Thanks for bringing up those points. They definitely make a compelling argument that this should be included in the core. In fact it's compelling enough that we'll default to enabling this in 1.9. In the meantime, we will add the option now (for 1.8.11) but have it off by default in order to not break back-compat in a minor release.

Thanks again.

comment:15 Changed 3 years ago by scott.gonzalez

  • Status changed from reopened to open

The new option should be called autoFocus to indicate that it is just focusing and not selecting. This also matches the naming of autoSelect (even though autoSelect isn't built in).

comment:16 Changed 3 years ago by scott.gonzalez

  • Description modified (diff)

comment:17 Changed 3 years ago by scott.gonzalez

  • Description modified (diff)

comment:18 Changed 3 years ago by Richard Worth

  • Status changed from open to closed
  • Resolution set to fixed

Autocomplete: new option autoFocus, default false. Fixed #7032 - Autocomplete: Add option to automatically highlight the first result

Changeset: 09215ef2cda488cafa92c42a8c63e2f1131147d0

comment:19 Changed 3 years ago by Richard Worth

Autocomplete: new option autoFocus, default false. Fixed #7032 - Autocomplete: Add option to automatically highlight the first result

Changeset: 779df6517d4e1bdd7ed3667537adb67c7443d15f

comment:20 Changed 3 years ago by scott.gonzalez

  • Status changed from closed to reopened
  • Resolution fixed deleted

This needs tests.

comment:21 Changed 3 years ago by Richard Worth

  • Status changed from reopened to closed
  • Resolution set to fixed

Autocomplete: added unit tests for autoFocus. Fixed #7032 - Autocomplete: Add option to automatically highlight the first result

Changeset: 56b7ec134d8e1203f700f99dabcdad8c50a9b0c2

comment:22 Changed 3 years ago by Richard Worth

Autocomplete: added unit tests for autoFocus. Fixed #7032 - Autocomplete: Add option to automatically highlight the first result (cherry picked from commit 56b7ec134d8e1203f700f99dabcdad8c50a9b0c2)

Changeset: 218100e7042cdf0a27fd1f3b7a954944878838f9

Note: See TracTickets for help on using tickets.