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.

Auto-highlight only option

See original GitHub issue

It would be handy to select the first value in the dropdown on pressing ENTER even if that value is not selected

  case _keyCode.RETURN:
    // Prevent submitting forms.
    e.preventDefault();

    if (this.state.showMenu) {
      var selected = options[activeIndex] || options[0];
      selected && this._handleAddOption(selected);
    }
    break;

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
mvolkmanncommented, Jan 6, 2017

Thanks @daschi, that was very helpful! Here’s a similar implementation that doesn’t require jQuery.

  fixTypeahead() {
    const {container} = this;
    if (!container) return;

    const input = container.querySelector('input');
    if (input.onkeydown) return; // don't need to set this up again

    input.onkeydown = event => {
      if (event.keyCode !== 13) return;
      const items = container.querySelectorAll('.bootstrap-typeahead-menu > li');
      if (items.length === 1) items[0].querySelector('a').click();
    };
  }

I call this from componentDidMount and componentDidUpdate.

I wrap my Typeahead in a div like this:

<div ref={saveTypeahead}> ... </div>

And here is saveTypeahead:

const saveTypeahead = c => this.container = c;
3reactions
ericgiocommented, Jul 21, 2017

highlightOnlyResult prop added in v2.0.0-alpha.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Highlight patterns and trends with conditional formatting in ...
If you want to locate only cells with the specific conditional format of the cell that you selected in step 1, under Options,...
Read more >
Highlight the Active Row and Column in a Data Range in Excel
In your example it is not necessary to go the F2 then enter route. Is there an option setting I am missing? Something...
Read more >
Auto Highlight|Wondershare Filmora Guide
There are 4 ways to launch the Auto Highlight feature in Filmora: 1. Open Filmora, you will see the Auto Highlight option at...
Read more >
How to highlight active row and column in Excel - Ablebits
Auto -highlight row and column of selected cell with VBA ... color of all cells on the sheet by setting the ColorIndex property...
Read more >
Create Advanced Highlight Actions - Tableau Help
Select - Click a mark in the view to run the action. This option works well for all types of actions. Menu -...
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