2
0

fix(editor): ️ Improve block focus

This commit is contained in:
Baptiste Arnaud
2022-03-29 10:23:45 +02:00
parent 1f992c6779
commit 261cd9a5c7
4 changed files with 22 additions and 3 deletions

View File

@ -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}