2
0

🐛 (engine) Fix button validation when item content includes a comma

This commit is contained in:
Baptiste Arnaud
2023-01-25 16:43:25 +01:00
parent 79622c6884
commit 07f26262ef
3 changed files with 9 additions and 7 deletions

View File

@ -41,7 +41,13 @@ export const CreateNewTypebotButtons = () => {
...typebot.theme,
chat: {
...typebot.theme.chat,
hostAvatar: { isEnabled: true, url: user.image ?? undefined },
hostAvatar: {
isEnabled: true,
url:
typebot.theme.chat.hostAvatar?.url ??
user.image ??
undefined,
},
},
},
},

View File

@ -3,9 +3,4 @@ import { ChoiceInputBlock } from 'models'
export const validateButtonInput = (
buttonBlock: ChoiceInputBlock,
input: string
) =>
input
.split(',')
.every((value) =>
buttonBlock.items.some((item) => item.content === value.trim())
)
) => buttonBlock.items.some((item) => item.content === input)

View File

@ -223,6 +223,7 @@ export const isReplyValid = (inputValue: string, block: Block): boolean => {
case InputBlockType.URL:
return validateUrl(inputValue)
case InputBlockType.CHOICE:
if (block.options.isMultipleChoice) return true
return validateButtonInput(block, inputValue)
}
return true