PollForm: autosuggest fix
This commit is contained in:
parent
7e7dd19b02
commit
2c4a28288d
1 changed files with 7 additions and 2 deletions
|
@ -10,6 +10,8 @@ import IconButton from 'soapbox/components/icon_button';
|
||||||
import { HStack } from 'soapbox/components/ui';
|
import { HStack } from 'soapbox/components/ui';
|
||||||
import { useAppSelector } from 'soapbox/hooks';
|
import { useAppSelector } from 'soapbox/hooks';
|
||||||
|
|
||||||
|
import type { AutoSuggestion } from 'soapbox/components/autosuggest_input';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
option_placeholder: { id: 'compose_form.poll.option_placeholder', defaultMessage: 'Choice {number}' },
|
option_placeholder: { id: 'compose_form.poll.option_placeholder', defaultMessage: 'Choice {number}' },
|
||||||
add_option: { id: 'compose_form.poll.add_option', defaultMessage: 'Add a choice' },
|
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 onSuggestionsFetchRequested = (token: string) => onFetchSuggestions(token);
|
||||||
|
|
||||||
const onSuggestionSelected = (tokenStart: number, token: string, value: string) =>
|
const onSuggestionSelected = (tokenStart: number, token: string | null, value: AutoSuggestion) => {
|
||||||
props.onSuggestionSelected(tokenStart, token, value, ['poll', 'options', index]);
|
if (token && typeof value === 'string') {
|
||||||
|
props.onSuggestionSelected(tokenStart, token, value, ['poll', 'options', index]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li>
|
<li>
|
||||||
|
|
Loading…
Reference in a new issue