2
0

🐛 Fix outside click on picture choice

This commit is contained in:
Baptiste Arnaud
2023-05-26 18:06:46 +02:00
parent 4dec06fc75
commit 4230f47be9
2 changed files with 38 additions and 34 deletions

View File

@@ -5,11 +5,10 @@ import {
Button,
HStack,
Popover,
PopoverAnchor,
PopoverContent,
PopoverTrigger,
Stack,
Text,
useDisclosure,
} from '@chakra-ui/react'
import { ImageUploadContent } from '@/components/ImageUploadContent'
@@ -24,12 +23,10 @@ export const PictureChoiceItemSettings = ({
item,
onItemChange,
}: Props) => {
const { isOpen, onOpen, onClose } = useDisclosure()
const updateTitle = (title: string) => onItemChange({ ...item, title })
const updateImage = (pictureSrc: string) => {
onItemChange({ ...item, pictureSrc })
onClose()
}
const updateDescription = (description: string) =>
@@ -39,19 +36,25 @@ export const PictureChoiceItemSettings = ({
<Stack>
<HStack>
<Text fontWeight="medium">Image:</Text>
<Popover isLazy isOpen={isOpen}>
<PopoverAnchor>
<Button size="sm" onClick={onOpen}>
Pick an image
</Button>
</PopoverAnchor>
<PopoverContent p="4" w="500px">
<ImageUploadContent
filePath={`typebots/${typebotId}/blocks/${item.blockId}/items/${item.id}`}
defaultUrl={item.pictureSrc}
onSubmit={updateImage}
/>
</PopoverContent>
<Popover isLazy>
{({ onClose }) => (
<>
<PopoverTrigger>
<Button size="sm">Pick an image</Button>
</PopoverTrigger>
<PopoverContent p="4" w="500px">
<ImageUploadContent
filePath={`typebots/${typebotId}/blocks/${item.blockId}/items/${item.id}`}
defaultUrl={item.pictureSrc}
onSubmit={(url) => {
updateImage(url)
onClose()
}}
excludedTabs={['emoji']}
/>
</PopoverContent>
</>
)}
</Popover>
</HStack>
<TextInput

View File

@@ -10,11 +10,10 @@ import {
MenuItem,
MenuList,
Popover,
PopoverAnchor,
PopoverContent,
PopoverTrigger,
Stack,
Text,
useDisclosure,
} from '@chakra-ui/react'
import { ButtonTheme } from '@typebot.io/js/dist/features/bubble/types'
import React from 'react'
@@ -25,8 +24,6 @@ type Props = {
}
export const ButtonThemeSettings = ({ buttonTheme, onChange }: Props) => {
const { isOpen, onOpen, onClose } = useDisclosure()
const updateBackgroundColor = (backgroundColor: string) => {
onChange({
...buttonTheme,
@@ -39,7 +36,6 @@ export const ButtonThemeSettings = ({ buttonTheme, onChange }: Props) => {
...buttonTheme,
customIconSrc,
})
onClose()
}
const updateSize = (size: ButtonTheme['size']) =>
@@ -73,18 +69,23 @@ export const ButtonThemeSettings = ({ buttonTheme, onChange }: Props) => {
</HStack>
<HStack justify="space-between">
<Text>Custom icon</Text>
<Popover isLazy isOpen={isOpen}>
<PopoverAnchor>
<Button size="sm" onClick={onOpen}>
Pick an image
</Button>
</PopoverAnchor>
<PopoverContent p="4" w="500px">
<ImageUploadContent
onSubmit={updateCustomIconSrc}
filePath={undefined}
/>
</PopoverContent>
<Popover isLazy>
{({ onClose }) => (
<>
<PopoverTrigger>
<Button size="sm">Pick an image</Button>
</PopoverTrigger>
<PopoverContent p="4" w="500px">
<ImageUploadContent
onSubmit={(url) => {
updateCustomIconSrc(url)
onClose()
}}
filePath={undefined}
/>
</PopoverContent>
</>
)}
</Popover>
</HStack>
</Stack>