Skip to content

Commit

Permalink
Fixed: Dynamic buttons should display unique items
Browse files Browse the repository at this point in the history
  • Loading branch information
Nil2000 committed Dec 13, 2024
1 parent 11503dc commit ab914ea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/embeds/js/src/components/InputChatBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ const Input = (props: {
?.success ?? defaultPaymentInputOptions.labels.success,
});

const handleUniqueItems= (items: ChoiceInputBlock["items"]) => {
return Array.from(new Map(items.map((item) => [item.content, item])).values());
}

return (
<Switch>
<Match when={props.block.type === InputBlockType.TEXT}>
Expand Down Expand Up @@ -207,14 +211,14 @@ const Input = (props: {
<Match when={!block.options?.isMultipleChoice}>
<Buttons
chunkIndex={props.chunkIndex}
defaultItems={block.items}
defaultItems={handleUniqueItems(block.items)}
options={block.options}
onSubmit={onSubmit}
/>
</Match>
<Match when={block.options?.isMultipleChoice}>
<MultipleChoicesForm
defaultItems={block.items}
defaultItems={handleUniqueItems(block.items)}
options={block.options}
onSubmit={onSubmit}
/>
Expand Down

0 comments on commit ab914ea

Please sign in to comment.