🐛 Fix edge dropping on condition block when all conditions ar…
This commit is contained in:
@ -12,6 +12,7 @@ import { Draft, produce } from 'immer'
|
||||
import { byId, isDefined } from '@typebot.io/lib'
|
||||
import { blockHasItems } from '@typebot.io/schemas/helpers'
|
||||
import { createId } from '@paralleldrive/cuid2'
|
||||
import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/constants'
|
||||
|
||||
export type EdgesActions = {
|
||||
createEdge: (edge: Omit<Edge, 'id'>) => void
|
||||
@ -67,7 +68,11 @@ export const edgesAction = (setTypebot: SetTypebot): EdgesActions => ({
|
||||
const areAllItemsConnected = (block as BlockWithItems).items.every(
|
||||
(item) => isDefined(item.outgoingEdgeId)
|
||||
)
|
||||
if (areAllItemsConnected) {
|
||||
if (
|
||||
areAllItemsConnected &&
|
||||
(block.type === InputBlockType.CHOICE ||
|
||||
block.type === InputBlockType.PICTURE_CHOICE)
|
||||
) {
|
||||
deleteEdgeDraft({
|
||||
typebot,
|
||||
edgeId: block.outgoingEdgeId,
|
||||
|
@ -12,6 +12,7 @@ import { ConnectingIds } from '../../types'
|
||||
import { useEventsCoordinates } from '../../providers/EventsCoordinateProvider'
|
||||
import { eventWidth, groupWidth } from '../../constants'
|
||||
import { useGroupsStore } from '../../hooks/useGroupsStore'
|
||||
import { omit } from '@typebot.io/lib'
|
||||
|
||||
type Props = {
|
||||
connectingIds: ConnectingIds
|
||||
@ -113,7 +114,13 @@ export const DrawingEdge = ({ connectingIds }: Props) => {
|
||||
|
||||
const createNewEdge = (connectingIds: ConnectingIds) => {
|
||||
assert(connectingIds.target)
|
||||
createEdge({ from: connectingIds.source, to: connectingIds.target })
|
||||
createEdge({
|
||||
from:
|
||||
'groupId' in connectingIds.source
|
||||
? omit(connectingIds.source, 'groupId')
|
||||
: connectingIds.source,
|
||||
to: connectingIds.target,
|
||||
})
|
||||
}
|
||||
|
||||
if (mousePosition && mousePosition.x === 0 && mousePosition.y === 0)
|
||||
|
Reference in New Issue
Block a user