diff --git a/apps/builder/src/components/VariableSearchInput.tsx b/apps/builder/src/components/VariableSearchInput.tsx index a5d1826ec..b1e239f22 100644 --- a/apps/builder/src/components/VariableSearchInput.tsx +++ b/apps/builder/src/components/VariableSearchInput.tsx @@ -25,7 +25,9 @@ import { useParentModal } from '@/features/graph/providers/ParentModalProvider' type Props = { initialVariableId?: string autoFocus?: boolean - onSelectVariable: (variable: Pick) => void + onSelectVariable: ( + variable: Pick | undefined + ) => void } & InputProps export const VariableSearchInput = ({ @@ -68,6 +70,9 @@ export const VariableSearchInput = ({ const onInputChange = (e: ChangeEvent) => { setInputValue(e.target.value) if (e.target.value === '') { + if (inputValue.length > 0) { + onSelectVariable(undefined) + } setFilteredItems([...variables.slice(0, 50)]) return } diff --git a/apps/builder/src/features/graph/components/Nodes/GroupNode/GroupNode.tsx b/apps/builder/src/features/graph/components/Nodes/GroupNode/GroupNode.tsx index f039814e5..fae324341 100644 --- a/apps/builder/src/features/graph/components/Nodes/GroupNode/GroupNode.tsx +++ b/apps/builder/src/features/graph/components/Nodes/GroupNode/GroupNode.tsx @@ -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, @@ -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 = { @@ -179,14 +177,6 @@ const NonMemoizedDraggableGroupNode = ({ } ) - const focusGroup = () => { - if (ignoreNextFocusIntent) { - setIgnoreNextFocusIntent(false) - return - } - setIsFocused(true) - } - return ( renderMenu={() => } @@ -195,7 +185,6 @@ const NonMemoizedDraggableGroupNode = ({ {(ref, isContextMenuOpened) => ( { } export const hasDefaultConnector = (block: Block) => - !isChoiceInput(block) && !isConditionBlock(block) + (!isChoiceInput(block) && !isConditionBlock(block)) || + (block.type === InputBlockType.CHOICE && + isDefined(block.options.dynamicVariableId)) diff --git a/apps/builder/src/features/variables/components/VariablesButton.tsx b/apps/builder/src/features/variables/components/VariablesButton.tsx index b51f7a11f..da53fb408 100644 --- a/apps/builder/src/features/variables/components/VariablesButton.tsx +++ b/apps/builder/src/features/variables/components/VariablesButton.tsx @@ -46,7 +46,7 @@ export const VariablesButton = ({ onSelectVariable, ...props }: Props) => { { onClose() - onSelectVariable(variable) + if (variable) onSelectVariable(variable) }} placeholder="Search for a variable" shadow="lg"