question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Autocomplete] New API to control the highlighted option

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

Typing into the auto-complete and pressing enter should select something, such as the suggested option. The suggested option to select should be highlighted.

Examples 🌈

For example type in Good into the playground and press enter, nothing gets selected.

Lets say I have a text matching score when searching for Good as following: The Good, the Bad and the Ugly = 0.3 Goodfellas = 0.8

I would want Goodfellas to be highlighted and selected when enter is pressed.

Motivation 🔦

The current auto-complete logic makes suggesting an option difficult.

Passing in a highlightedValue/suggestedValue would make the above possible. Set the first value in the list to be highlighted if one is not provided.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:9
  • Comments:24 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
jatin-raocommented, Jun 16, 2021

Ok @oliviertassinari so my use case is as Follows:

My Autocomplete should work like a time picker. Like the user will be shown suggestions of time from 12:00 am to 12:00 pm with 15 minutes interval like (12:00AM, 12:15AM, 12:30AM and so on till 11:45PM) and when an user edits the time in text field like he writes 10:40AM so the autocomplete should automatically highlight the closest option like 10:45AM in popup menu. Even if it can’t highlight the closest option, it should be able to move the scrollbar in popup to 10:45AM.

I have searched a lot about how to change focus inside popup programmatically but was not able to find anything. Do you have any suggestion on how to achieve this?

1reaction
KamalAmancommented, May 11, 2020

@oliviertassinari Yeah, it seems like that api would work for us. Yes keeping the highlight state inside a ref if not controlled makes perfect sense. We don’t want to pull the highlighted value to the top of the list since the list is sorted/grouped.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Autocomplete] New API to control the highlighted option #20852
The current auto-complete logic makes suggesting an option difficult. Passing in a highlightedValue/suggestedValue would make the above possible ...
Read more >
Autocomplete API - Material UI - MUI
Name Type Default options * array renderInput * func autoComplete bool false
Read more >
What to highlight in autosuggest options? - UX Stack Exchange
Option 1, highlighting the text input by the user and not highlighting the auto-complete suggestion completely breaks with established ...
Read more >
Place Autocomplete | Places API - Google Developers
Pass the string ipbias (this option has no additional parameters). ... Be sure to pass a unique session token for each new session....
Read more >
How to highlight input words in autocomplete jquery ui
@nness: If you need highlight just text you can use .toUpperCase().indexOf() to locate the substring this.term in the string item.value . You can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found