2
0

🐛 (bot) Fix reactivity issue when filtering single choices

Closes #803
This commit is contained in:
Baptiste Arnaud
2023-09-25 11:30:13 +02:00
parent 2307231d28
commit 459fc4debc
5 changed files with 7 additions and 10 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@typebot.io/js", "name": "@typebot.io/js",
"version": "0.1.29", "version": "0.1.30",
"description": "Javascript library to display typebots on your website", "description": "Javascript library to display typebots on your website",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -21,8 +21,7 @@ export const Buttons = (props: Props) => {
if (!isMobile() && inputRef) inputRef.focus() if (!isMobile() && inputRef) inputRef.focus()
}) })
// eslint-disable-next-line solid/reactivity const handleClick = (itemIndex: number) =>
const handleClick = (itemIndex: number) => () =>
props.onSubmit({ value: filteredItems()[itemIndex].content ?? '' }) props.onSubmit({ value: filteredItems()[itemIndex].content ?? '' })
const filterItems = (inputValue: string) => { const filterItems = (inputValue: string) => {
@ -61,7 +60,7 @@ export const Buttons = (props: Props) => {
{(item, index) => ( {(item, index) => (
<span class={'relative' + (isMobile() ? ' w-full' : '')}> <span class={'relative' + (isMobile() ? ' w-full' : '')}>
<Button <Button
on:click={handleClick(index())} on:click={() => handleClick(index())}
data-itemid={item.id} data-itemid={item.id}
class="w-full" class="w-full"
> >

View File

@ -19,8 +19,7 @@ export const SinglePictureChoice = (props: Props) => {
if (!isMobile() && inputRef) inputRef.focus() if (!isMobile() && inputRef) inputRef.focus()
}) })
// eslint-disable-next-line solid/reactivity const handleClick = (itemIndex: number) => {
const handleClick = (itemIndex: number) => () => {
const pictureSrc = filteredItems()[itemIndex].pictureSrc const pictureSrc = filteredItems()[itemIndex].pictureSrc
if (!pictureSrc) return if (!pictureSrc) return
return props.onSubmit({ return props.onSubmit({
@ -65,8 +64,7 @@ export const SinglePictureChoice = (props: Props) => {
<For each={filteredItems()}> <For each={filteredItems()}>
{(item, index) => ( {(item, index) => (
<button <button
// eslint-disable-next-line solid/reactivity on:click={() => handleClick(index())}
on:click={handleClick(index())}
data-itemid={item.id} data-itemid={item.id}
class={ class={
'flex flex-col typebot-picture-button focus:outline-none filter hover:brightness-90 active:brightness-75 justify-between ' + 'flex flex-col typebot-picture-button focus:outline-none filter hover:brightness-90 active:brightness-75 justify-between ' +

View File

@ -1,6 +1,6 @@
{ {
"name": "@typebot.io/nextjs", "name": "@typebot.io/nextjs",
"version": "0.1.29", "version": "0.1.30",
"description": "Convenient library to display typebots on your Next.js website", "description": "Convenient library to display typebots on your Next.js website",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@ -1,6 +1,6 @@
{ {
"name": "@typebot.io/react", "name": "@typebot.io/react",
"version": "0.1.29", "version": "0.1.30",
"description": "Convenient library to display typebots on your React app", "description": "Convenient library to display typebots on your React app",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",