Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

45 lines (33 sloc) 1.28 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({ containerProps, children }) {
  const { ref, ...restContainerProps } = containerProps;
  const callRef = isolatedScroll => {
    if (isolatedScroll !== null) {
      ref(isolatedScroll.component);
    }
  };

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

<Autosuggest renderSuggestionsContainer={renderSuggestionsContainer} ... />
You can’t perform that action at this time.