1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-02 16:58:53 +09:00

autoscroll emoji suggestions box

This commit is contained in:
Ondřej Hruška 2017-09-21 15:31:24 +02:00
parent fa3587645d
commit c89cce0219

View File

@ -162,6 +162,15 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
}
}
componentDidUpdate () {
if (this.refs.selected) {
if (this.refs.selected.scrollIntoViewIfNeeded)
this.refs.selected.scrollIntoViewIfNeeded();
else
this.refs.selected.scrollIntoView({ behavior: 'auto', block: 'nearest' });
}
}
render () {
const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus } = this.props;
const { suggestionsHidden, selectedSuggestion } = this.state;
@ -202,6 +211,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
<div className={`autosuggest-textarea__suggestions ${suggestionsHidden || suggestions.isEmpty() ? '' : 'autosuggest-textarea__suggestions--visible'}`}>
{suggestions.map((suggestion, i) => (
<div
ref={i === selectedSuggestion ? 'selected' : null}
role='button'
tabIndex='0'
key={suggestion}