🐛 (buttons) Fix dynamic buttons edge not showing
This commit is contained in:
@ -25,7 +25,9 @@ import { useParentModal } from '@/features/graph/providers/ParentModalProvider'
|
|||||||
type Props = {
|
type Props = {
|
||||||
initialVariableId?: string
|
initialVariableId?: string
|
||||||
autoFocus?: boolean
|
autoFocus?: boolean
|
||||||
onSelectVariable: (variable: Pick<Variable, 'id' | 'name'>) => void
|
onSelectVariable: (
|
||||||
|
variable: Pick<Variable, 'id' | 'name'> | undefined
|
||||||
|
) => void
|
||||||
} & InputProps
|
} & InputProps
|
||||||
|
|
||||||
export const VariableSearchInput = ({
|
export const VariableSearchInput = ({
|
||||||
@ -68,6 +70,9 @@ export const VariableSearchInput = ({
|
|||||||
const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {
|
const onInputChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
setInputValue(e.target.value)
|
setInputValue(e.target.value)
|
||||||
if (e.target.value === '') {
|
if (e.target.value === '') {
|
||||||
|
if (inputValue.length > 0) {
|
||||||
|
onSelectVariable(undefined)
|
||||||
|
}
|
||||||
setFilteredItems([...variables.slice(0, 50)])
|
setFilteredItems([...variables.slice(0, 50)])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,6 @@ const NonMemoizedDraggableGroupNode = ({
|
|||||||
const [debouncedGroupPosition] = useDebounce(currentCoordinates, 100)
|
const [debouncedGroupPosition] = useDebounce(currentCoordinates, 100)
|
||||||
const [isFocused, setIsFocused] = useState(false)
|
const [isFocused, setIsFocused] = useState(false)
|
||||||
|
|
||||||
const [ignoreNextFocusIntent, setIgnoreNextFocusIntent] = useState(false)
|
|
||||||
|
|
||||||
useOutsideClick({
|
useOutsideClick({
|
||||||
handler: () => setIsFocused(false),
|
handler: () => setIsFocused(false),
|
||||||
ref: groupRef,
|
ref: groupRef,
|
||||||
@ -151,15 +149,15 @@ const NonMemoizedDraggableGroupNode = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
useDrag(
|
useDrag(
|
||||||
({ first, last, offset: [offsetX, offsetY], distance, event, target }) => {
|
({ first, last, offset: [offsetX, offsetY], event, target }) => {
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
if ((target as HTMLElement).classList.contains('prevent-group-drag'))
|
if ((target as HTMLElement).classList.contains('prevent-group-drag'))
|
||||||
return
|
return
|
||||||
if (first) {
|
if (first) {
|
||||||
|
setIsFocused(true)
|
||||||
setIsMouseDown(true)
|
setIsMouseDown(true)
|
||||||
}
|
}
|
||||||
if (last) {
|
if (last) {
|
||||||
if (distance[0] > 1 || distance[1] > 1) setIgnoreNextFocusIntent(true)
|
|
||||||
setIsMouseDown(false)
|
setIsMouseDown(false)
|
||||||
}
|
}
|
||||||
const newCoord = {
|
const newCoord = {
|
||||||
@ -179,14 +177,6 @@ const NonMemoizedDraggableGroupNode = ({
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const focusGroup = () => {
|
|
||||||
if (ignoreNextFocusIntent) {
|
|
||||||
setIgnoreNextFocusIntent(false)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setIsFocused(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ContextMenu<HTMLDivElement>
|
<ContextMenu<HTMLDivElement>
|
||||||
renderMenu={() => <GroupNodeContextMenu groupIndex={groupIndex} />}
|
renderMenu={() => <GroupNodeContextMenu groupIndex={groupIndex} />}
|
||||||
@ -195,7 +185,6 @@ const NonMemoizedDraggableGroupNode = ({
|
|||||||
{(ref, isContextMenuOpened) => (
|
{(ref, isContextMenuOpened) => (
|
||||||
<Stack
|
<Stack
|
||||||
ref={setMultipleRefs([ref, groupRef])}
|
ref={setMultipleRefs([ref, groupRef])}
|
||||||
onClick={focusGroup}
|
|
||||||
data-testid="group"
|
data-testid="group"
|
||||||
p="4"
|
p="4"
|
||||||
rounded="xl"
|
rounded="xl"
|
||||||
|
@ -56,6 +56,7 @@ import {
|
|||||||
blockTypeHasItems,
|
blockTypeHasItems,
|
||||||
isChoiceInput,
|
isChoiceInput,
|
||||||
isConditionBlock,
|
isConditionBlock,
|
||||||
|
isDefined,
|
||||||
} from 'utils'
|
} from 'utils'
|
||||||
|
|
||||||
const roundSize = 20
|
const roundSize = 20
|
||||||
@ -456,4 +457,6 @@ const parseDefaultBlockOptions = (type: BlockWithOptionsType): BlockOptions => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const hasDefaultConnector = (block: Block) =>
|
export const hasDefaultConnector = (block: Block) =>
|
||||||
!isChoiceInput(block) && !isConditionBlock(block)
|
(!isChoiceInput(block) && !isConditionBlock(block)) ||
|
||||||
|
(block.type === InputBlockType.CHOICE &&
|
||||||
|
isDefined(block.options.dynamicVariableId))
|
||||||
|
@ -46,7 +46,7 @@ export const VariablesButton = ({ onSelectVariable, ...props }: Props) => {
|
|||||||
<VariableSearchInput
|
<VariableSearchInput
|
||||||
onSelectVariable={(variable) => {
|
onSelectVariable={(variable) => {
|
||||||
onClose()
|
onClose()
|
||||||
onSelectVariable(variable)
|
if (variable) onSelectVariable(variable)
|
||||||
}}
|
}}
|
||||||
placeholder="Search for a variable"
|
placeholder="Search for a variable"
|
||||||
shadow="lg"
|
shadow="lg"
|
||||||
|
Reference in New Issue
Block a user