Skip to content

Latest commit

 

History

History
41 lines (30 loc) · 1.16 KB

FAQ.md

File metadata and controls

41 lines (30 loc) · 1.16 KB

How do I get the input element?

The input element is available on the Autosuggest instance as input.

You could store the input element like this:

function storeInputReference(autosuggest) {
  if (autosuggest !== null) {
    this.input = autosuggest.input;
  }
}

<Autosuggest ref={storeInputReference} ... />

Codepen example

How do I limit the scrolling of the suggestions container to the container itself?

When the suggestions container has a scroll bar, and you scroll beyond the start/end of the container, the page starts scrolling. To stop that, you can use react-isolated-scroll:

import IsolatedScroll from 'react-isolated-scroll';

function renderSuggestionsContainer({ ref, ...rest }) {
  const callRef = isolatedScroll => {
    if (isolatedScroll !== null) {
      ref(isolatedScroll.component);
    }
  };

  return (
    <IsolatedScroll {...rest} ref={callRef} />
  );
}

<Autosuggest renderSuggestionsContainer={renderSuggestionsContainer} ... />