palantir/blueprint

Question: [Omnibar]: How do I get the keyboard controls to work when initialContent is displayed?

Open

#3.160 geöffnet am 16. Nov. 2018

Auf GitHub ansehen
 (10 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (20.263 Stars) (2.167 Forks)batch import
Package: selectType: enhancementhelp wanted

Beschreibung

Environment

  • Package version(s): @blueprintjs/core - v3.7.0 & @blueprintjs/select v3.2.0
  • Browser and OS versions: Chrome v70 / macOS Sierra

Question

I'm using Omnibar in https://pasteapp.com.

My setup is as follows;

  1. I have a React Component Foo
  2. The component Foo is stateful
  3. The state is composed of items and filtered items
  4. The component renders Omnibar like this;
<Omnibar
  isOpen={this.props.isOpen}
  itemRenderer={this.renderItem}
  onQueryChange={this.handleQueryChange}
  items={this.state.filteredItems}
  onItemSelect={this.props.onItemSelect}
  onClose={this.props.onClose}
  inputProps={{
    leftIcon: null
  }}
/>

It works just fine, I can use keyboard controls (arrow keys) to go up/down in the results, however, as soon as I introduce initialContent like this;

<Omnibar
  ...
  initialContent={this.state.items.slice(0, 10).map(this.renderItem)}
/>

...the items are shown, but I can't use the keyboard controls anymore. No exceptions were thrown, or errors were logged.

What am I doing wrong here?

Contributor Guide