autoscroll emoji suggestions box

master
Ondřej Hruška 7 years ago
parent fa3587645d
commit c89cce0219
  1. 10
      app/javascript/mastodon/components/autosuggest_textarea.js

@ -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 () { render () {
const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus } = this.props; const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus } = this.props;
const { suggestionsHidden, selectedSuggestion } = this.state; 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'}`}> <div className={`autosuggest-textarea__suggestions ${suggestionsHidden || suggestions.isEmpty() ? '' : 'autosuggest-textarea__suggestions--visible'}`}>
{suggestions.map((suggestion, i) => ( {suggestions.map((suggestion, i) => (
<div <div
ref={i === selectedSuggestion ? 'selected' : null}
role='button' role='button'
tabIndex='0' tabIndex='0'
key={suggestion} key={suggestion}

Loading…
Cancel
Save