site-logo-fallback
Justin 2022-05-16 11:21:17 -04:00
rodzic beb58a7d86
commit 7b9db5299a
1 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -14,7 +14,7 @@ import AutosuggestEmoji from './autosuggest_emoji';
const textAtCursorMatchesToken = (str, caretPosition) => { const textAtCursorMatchesToken = (str, caretPosition) => {
let word; let word;
const left = str.slice(0, caretPosition).search(/\S+$/); const left = str.slice(0, caretPosition).search(/\S+$/);
const right = str.slice(caretPosition).search(/\s/); const right = str.slice(caretPosition).search(/\s/);
if (right < 0) { if (right < 0) {
@ -69,7 +69,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
}; };
onChange = (e) => { onChange = (e) => {
const [ tokenStart, token ] = textAtCursorMatchesToken(e.target.value, e.target.selectionStart); const [tokenStart, token] = textAtCursorMatchesToken(e.target.value, e.target.selectionStart);
if (token !== null && this.state.lastToken !== token) { if (token !== null && this.state.lastToken !== token) {
this.setState({ lastToken: token, selectedSuggestion: 0, tokenStart }); this.setState({ lastToken: token, selectedSuggestion: 0, tokenStart });
@ -123,7 +123,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
break; break;
case 'Enter': case 'Enter':
case 'Tab': case 'Tab':
// Select suggestion // Select suggestion
if (this.state.lastToken !== null && suggestions.size > 0 && !suggestionsHidden) { if (this.state.lastToken !== null && suggestions.size > 0 && !suggestionsHidden) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -200,13 +200,13 @@ export default class AutosuggestTextarea extends ImmutablePureComponent {
if (typeof suggestion === 'object') { if (typeof suggestion === 'object') {
inner = <AutosuggestEmoji emoji={suggestion} />; inner = <AutosuggestEmoji emoji={suggestion} />;
key = suggestion.id; key = suggestion.id;
} else if (suggestion[0] === '#') { } else if (suggestion[0] === '#') {
inner = suggestion; inner = suggestion;
key = suggestion; key = suggestion;
} else { } else {
inner = <AutosuggestAccount id={suggestion} />; inner = <AutosuggestAccount id={suggestion} />;
key = suggestion; key = suggestion;
} }
return ( return (