Skip to content

Latest commit

 

History

History
44 lines (33 loc) · 1.28 KB

FAQ.md

File metadata and controls

44 lines (33 loc) · 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} ... />