Skip to content

Commit

Permalink
🐛 (buttons) Fix dynamic buttons edge not showing
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 23, 2023
1 parent 0619c60 commit e1b7320
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
7 changes: 6 additions & 1 deletion apps/builder/src/components/VariableSearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import { useParentModal } from '@/features/graph/providers/ParentModalProvider'
type Props = {
initialVariableId?: string
autoFocus?: boolean
onSelectVariable: (variable: Pick<Variable, 'id' | 'name'>) => void
onSelectVariable: (
variable: Pick<Variable, 'id' | 'name'> | undefined
) => void
} & InputProps

export const VariableSearchInput = ({
Expand Down Expand Up @@ -68,6 +70,9 @@ export const VariableSearchInput = ({
const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {
setInputValue(e.target.value)
if (e.target.value === '') {
if (inputValue.length > 0) {
onSelectVariable(undefined)
}
setFilteredItems([...variables.slice(0, 50)])
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ const NonMemoizedDraggableGroupNode = ({
const [debouncedGroupPosition] = useDebounce(currentCoordinates, 100)
const [isFocused, setIsFocused] = useState(false)

const [ignoreNextFocusIntent, setIgnoreNextFocusIntent] = useState(false)

useOutsideClick({
handler: () => setIsFocused(false),
ref: groupRef,
Expand Down Expand Up @@ -151,15 +149,15 @@ const NonMemoizedDraggableGroupNode = ({
}

useDrag(
({ first, last, offset: [offsetX, offsetY], distance, event, target }) => {
({ first, last, offset: [offsetX, offsetY], event, target }) => {
event.stopPropagation()
if ((target as HTMLElement).classList.contains('prevent-group-drag'))
return
if (first) {
setIsFocused(true)
setIsMouseDown(true)
}
if (last) {
if (distance[0] > 1 || distance[1] > 1) setIgnoreNextFocusIntent(true)
setIsMouseDown(false)
}
const newCoord = {
Expand All @@ -179,14 +177,6 @@ const NonMemoizedDraggableGroupNode = ({
}
)

const focusGroup = () => {
if (ignoreNextFocusIntent) {
setIgnoreNextFocusIntent(false)
return
}
setIsFocused(true)
}

return (
<ContextMenu<HTMLDivElement>
renderMenu={() => <GroupNodeContextMenu groupIndex={groupIndex} />}
Expand All @@ -195,7 +185,6 @@ const NonMemoizedDraggableGroupNode = ({
{(ref, isContextMenuOpened) => (
<Stack
ref={setMultipleRefs([ref, groupRef])}
onClick={focusGroup}
data-testid="group"
p="4"
rounded="xl"
Expand Down
5 changes: 4 additions & 1 deletion apps/builder/src/features/graph/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import {
blockTypeHasItems,
isChoiceInput,
isConditionBlock,
isDefined,
} from 'utils'

const roundSize = 20
Expand Down Expand Up @@ -456,4 +457,6 @@ const parseDefaultBlockOptions = (type: BlockWithOptionsType): BlockOptions => {
}

export const hasDefaultConnector = (block: Block) =>
!isChoiceInput(block) && !isConditionBlock(block)
(!isChoiceInput(block) && !isConditionBlock(block)) ||
(block.type === InputBlockType.CHOICE &&
isDefined(block.options.dynamicVariableId))
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const VariablesButton = ({ onSelectVariable, ...props }: Props) => {
<VariableSearchInput
onSelectVariable={(variable) => {
onClose()
onSelectVariable(variable)
if (variable) onSelectVariable(variable)
}}
placeholder="Search for a variable"
shadow="lg"
Expand Down

3 comments on commit e1b7320

@vercel
Copy link

@vercel vercel bot commented on e1b7320 Feb 23, 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

ns8.vn
1stop.au
yobot.me
klujo.com
247987.com
8jours.top
aginap.com
bee.cr8.ai
bot.aws.bj
bot.bbc.bj
cat.cr8.ai
finplex.be
nepkit.com
pig.cr8.ai
sat.cr8.ai
bot.aipr.kr
bot.joof.it
bull.cr8.ai
docs.cr8.ai
minipost.uk
mole.cr8.ai
team.cr8.ai
wolf.cr8.ai
cinecorn.com
kusamint.com
rhino.cr8.ai
sheep.cr8.ai
snake.cr8.ai
svhm.mprs.in
tiger.cr8.ai
video.cr8.ai
yoda.riku.ai
zebra.cr8.ai
bergamo.store
bot.krdfy.com
bot.tvbeat.it
cgcassets.com
cnvhub.com.br
filmylogy.com
goldorayo.com
rabbit.cr8.ai
signup.cr8.ai
turkey.cr8.ai
vhpage.cr8.ai
vitamyway.com
am.nigerias.io
an.nigerias.io
app.yvon.earth
ar.nigerias.io
bot.enreso.org
bot.rslabs.pro
bots.bridge.ai
chat.hayuri.id
chicken.cr8.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

@vercel
Copy link

@vercel vercel bot commented on e1b7320 Feb 23, 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 e1b7320 Feb 23, 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.typebot.io
docs-git-main-typebot-io.vercel.app

Please sign in to comment.