fmoo / react-typeahead

Pure react-based typeahead and typeahead-tokenizer
ISC License
677 stars 232 forks source link

Tokenizer results are always on top #218

Open eeiswerth opened 7 years ago

eeiswerth commented 7 years ago

The way in which I laid out my page required that I had tokenizer results on the bottom of the input, rather than the top. The tokenizer doesn't support this natively, but you can use a trick like this to get around it and force the results to the bottom. It's not pretty, but it gets the job done.

<Tokenizer
    ref={(t) => {
        if (t) {
            var n = ReactDOM.findDOMNode(t);
            var selections = $(n).find('.typeahead-token');
            if (selections.length === 0) {
                // No selections. Nothing to do.
                return;
            }
            var tokens = $(n).find('.typeahead-token').detach();
            var input = $(n).find('.typeahead');
            tokens.insertAfter(input);
        }
    }}
/>