PollForm: autosuggest fix

dnd
Alex Gleason 2022-06-06 13:38:48 -05:00
rodzic 7e7dd19b02
commit 2c4a28288d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 7 dodań i 2 usunięć

Wyświetl plik

@ -10,6 +10,8 @@ import IconButton from 'soapbox/components/icon_button';
import { HStack } from 'soapbox/components/ui';
import { useAppSelector } from 'soapbox/hooks';
import type { AutoSuggestion } from 'soapbox/components/autosuggest_input';
const messages = defineMessages({
option_placeholder: { id: 'compose_form.poll.option_placeholder', defaultMessage: 'Choice {number}' },
add_option: { id: 'compose_form.poll.add_option', defaultMessage: 'Add a choice' },
@ -83,8 +85,11 @@ const Option = (props: IOption) => {
const onSuggestionsFetchRequested = (token: string) => onFetchSuggestions(token);
const onSuggestionSelected = (tokenStart: number, token: string, value: string) =>
props.onSuggestionSelected(tokenStart, token, value, ['poll', 'options', index]);
const onSuggestionSelected = (tokenStart: number, token: string | null, value: AutoSuggestion) => {
if (token && typeof value === 'string') {
props.onSuggestionSelected(tokenStart, token, value, ['poll', 'options', index]);
}
};
return (
<li>