fix(editor): ♿️ Improve block focus
This commit is contained in:
@ -30,6 +30,8 @@ export const BlockNode = ({ block, blockIndex }: Props) => {
|
||||
blocksCoordinates,
|
||||
updateBlockCoordinates,
|
||||
isReadOnly,
|
||||
focusedBlockId,
|
||||
setFocusedBlockId,
|
||||
} = useGraph()
|
||||
const { typebot, updateBlock } = useTypebot()
|
||||
const { setMouseOverBlock, mouseOverBlock } = useStepDnd()
|
||||
@ -91,7 +93,10 @@ export const BlockNode = ({ block, blockIndex }: Props) => {
|
||||
})
|
||||
}
|
||||
|
||||
const onDragStart = () => setIsMouseDown(true)
|
||||
const onDragStart = () => {
|
||||
setFocusedBlockId(block.id)
|
||||
setIsMouseDown(true)
|
||||
}
|
||||
const onDragStop = () => setIsMouseDown(false)
|
||||
return (
|
||||
<ContextMenu<HTMLDivElement>
|
||||
@ -131,6 +136,7 @@ export const BlockNode = ({ block, blockIndex }: Props) => {
|
||||
cursor={isMouseDown ? 'grabbing' : 'pointer'}
|
||||
boxShadow="0px 0px 0px 1px #e9edf3;"
|
||||
_hover={{ shadow: 'lg' }}
|
||||
zIndex={focusedBlockId === block.id ? 10 : 1}
|
||||
>
|
||||
<Editable
|
||||
defaultValue={block.title}
|
||||
|
@ -45,8 +45,13 @@ export const StepNode = ({
|
||||
onMouseDown?: (stepNodePosition: NodePosition, step: DraggableStep) => void
|
||||
}) => {
|
||||
const { query } = useRouter()
|
||||
const { setConnectingIds, connectingIds, openedStepId, setOpenedStepId } =
|
||||
useGraph()
|
||||
const {
|
||||
setConnectingIds,
|
||||
connectingIds,
|
||||
openedStepId,
|
||||
setOpenedStepId,
|
||||
setFocusedBlockId,
|
||||
} = useGraph()
|
||||
const { updateStep } = useTypebot()
|
||||
const [isConnecting, setIsConnecting] = useState(false)
|
||||
const [isPopoverOpened, setIsPopoverOpened] = useState(
|
||||
@ -113,6 +118,7 @@ export const StepNode = ({
|
||||
}
|
||||
|
||||
const handleClick = (e: React.MouseEvent) => {
|
||||
setFocusedBlockId(step.blockId)
|
||||
e.stopPropagation()
|
||||
if (isTextBubbleStep(step)) setIsEditing(true)
|
||||
setOpenedStepId(step.id)
|
||||
|
@ -75,6 +75,7 @@ export const VariableSearchInput = ({
|
||||
debounced(e.target.value)
|
||||
onOpen()
|
||||
if (e.target.value === '') {
|
||||
onSelectVariable(undefined)
|
||||
setFilteredItems([...variables.slice(0, 50)])
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user