Skip to content

Commit

Permalink
♿ (editor) Improve variables popover click detection
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 16, 2023
1 parent d805ea9 commit 618eb8a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
28 changes: 21 additions & 7 deletions apps/builder/src/features/variables/components/VariablesButton.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
import {
Popover,
PopoverTrigger,
Flex,
Tooltip,
IconButton,
PopoverContent,
IconButtonProps,
useDisclosure,
PopoverAnchor,
} from '@chakra-ui/react'
import { UserIcon } from '@/components/icons'
import { Variable } from 'models'
import React from 'react'
import React, { useRef } from 'react'
import { VariableSearchInput } from '@/components/VariableSearchInput'
import { useOutsideClick } from '@/hooks/useOutsideClick'

type Props = {
onSelectVariable: (variable: Pick<Variable, 'name' | 'id'>) => void
} & Omit<IconButtonProps, 'aria-label'>

export const VariablesButton = ({ onSelectVariable, ...props }: Props) => {
const { isOpen, onOpen, onClose } = useDisclosure()
const popoverRef = useRef<HTMLDivElement>(null)

useOutsideClick({
ref: popoverRef,
handler: onClose,
})

return (
<Popover isLazy placement="bottom-end" gutter={0}>
<PopoverTrigger>
<Popover isLazy placement="bottom-end" gutter={0} isOpen={isOpen}>
<PopoverAnchor>
<Flex>
<Tooltip label="Insert a variable">
<IconButton
aria-label={'Insert a variable'}
icon={<UserIcon />}
pos="relative"
onClick={onOpen}
{...props}
/>
</Tooltip>
</Flex>
</PopoverTrigger>
<PopoverContent w="full">
</PopoverAnchor>
<PopoverContent w="full" ref={popoverRef}>
<VariableSearchInput
onSelectVariable={onSelectVariable}
onSelectVariable={(variable) => {
onClose()
onSelectVariable(variable)
}}
placeholder="Search for a variable"
shadow="lg"
autoFocus
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/lib/plate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const platePlugins = createPlugins(
url.startsWith('https:') ||
url.startsWith('mailto:') ||
url.startsWith('tel:') ||
url.startsWith('sms:') ||
(url.startsWith('{{') && url.endsWith('}}')),
url.startsWith('sms:'),
forceSubmit: true,
},
}),
],
Expand Down

4 comments on commit 618eb8a

@vercel
Copy link

@vercel vercel bot commented on 618eb8a Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-typebot-io.vercel.app
docs-git-main-typebot-io.vercel.app
docs.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 618eb8a Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 618eb8a Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

an.nigerias.io
app.yvon.earth
ar.nigerias.io
bot.enreso.org
bot.rslabs.pro
bots.bridge.ai
chat.hayuri.id
chicken.cr8.ai
gollum.riku.ai
gsbulletin.com
panther.cr7.ai
myrentalhost.com
stan.vselise.com
start.taxtree.io
typebot.aloe.bot
voicehelp.cr8.ai
zap.fundviser.in
app.chatforms.net
bot.hostnation.de
bot.maitempah.com
bot.phuonghub.com
bot.reviewzer.com
bot.rihabilita.it
cares.urlabout.me
chat.gaswadern.de
fmm.wpwakanda.com
gentleman-shop.fr
k1.kandabrand.com
lb.ticketfute.com
ov1.wpwakanda.com
ov2.wpwakanda.com
ov3.wpwakanda.com
support.triplo.ai
viewer.typebot.io
1988.bouclidom.com
andreimayer.com.br
bot.danyservice.it
bot.iconicbrows.it
bot.megafox.com.br
bot.neferlopez.com
bots.robomotion.io
cadu.uninta.edu.br
dicanatural.online
digitalhelp.com.au
goalsettingbot.com
pant.maxbot.com.br
positivobra.com.br
survey.digienge.io
this-is-a-test.com
zap.techadviser.in
bot.boston-voip.com
bot.cabinpromos.com
bot.digitalbled.com
bot.dsignagency.com
bot.eventhub.com.au
bot.jepierre.com.br
bot.ltmidias.com.br
homepageonly.wpwakanda.com
liveconvert.kandalearn.com
mainmenu1one.wpwakanda.com
tarian.theiofoundation.org
ted.meujalecobrasil.com.br
type.dericsoncalari.com.br
bot.pinpointinteractive.com
bot.polychromes-project.com
bot.seidinembroseanchetu.it
chatbot.berbelanjabiz.trade
designguide.techyscouts.com
liveconvert2.kandalearn.com
presente.empresarias.com.mx
sell.sellthemotorhome.co.uk
anamnese.odontopavani.com.br
austin.channelautomation.com
bot.marketingplusmindset.com
bot.seidibergamoseanchetu.it
desabafe.sergiolimajr.com.br
download.venturemarketing.in
piazzatorre.barrettamario.it
type.cookieacademyonline.com
bot.brigadeirosemdrama.com.br
forms.escoladeautomacao.com.br
onboarding.libertydreamcare.ie
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
anamnese.clinicamegasjdr.com.br
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
elevateyourmind.groovepages.com
viewer-v2-typebot-io.vercel.app
yourfeedback.comebackreward.com
gerador.verificadordehospedes.com
personal-trainer.barrettamario.it
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
download.thailandmicespecialist.com
register.thailandmicespecialist.com
bot.studiotecnicoimmobiliaremerelli.it
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
viewer-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 618eb8a Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
app.typebot.io
builder-v2-typebot-io.vercel.app

Please sign in to comment.