2
0

fix(editor): 🐛 Start block was deletable

This commit is contained in:
Baptiste Arnaud
2022-02-25 08:15:30 +01:00
parent 4bb5a57f69
commit 8533bb92a8
2 changed files with 4 additions and 5 deletions

View File

@ -38,8 +38,7 @@ export const BlockNode = ({ block, blockIndex }: Props) => {
const isPreviewing = const isPreviewing =
previewingEdge?.to.blockId === block.id || previewingEdge?.to.blockId === block.id ||
previewingEdge?.from.blockId === block.id previewingEdge?.from.blockId === block.id
const isStartBlock = const isStartBlock = block.steps[0].type === 'start'
block.steps.length === 1 && block.steps[0].type === 'start'
const blockCoordinates = blocksCoordinates[block.id] const blockCoordinates = blocksCoordinates[block.id]
const blockRef = useRef<HTMLDivElement | null>(null) const blockRef = useRef<HTMLDivElement | null>(null)
@ -96,7 +95,7 @@ export const BlockNode = ({ block, blockIndex }: Props) => {
return ( return (
<ContextMenu<HTMLDivElement> <ContextMenu<HTMLDivElement>
renderMenu={() => <BlockNodeContextMenu blockIndex={blockIndex} />} renderMenu={() => <BlockNodeContextMenu blockIndex={blockIndex} />}
isDisabled={isReadOnly} isDisabled={isReadOnly || isStartBlock}
> >
{(ref, isOpened) => ( {(ref, isOpened) => (
<DraggableCore <DraggableCore
@ -135,7 +134,7 @@ export const BlockNode = ({ block, blockIndex }: Props) => {
defaultValue={block.title} defaultValue={block.title}
onSubmit={handleTitleSubmit} onSubmit={handleTitleSubmit}
fontWeight="semibold" fontWeight="semibold"
pointerEvents={isReadOnly ? 'none' : 'auto'} pointerEvents={isReadOnly || isStartBlock ? 'none' : 'auto'}
> >
<EditablePreview <EditablePreview
_hover={{ bgColor: 'gray.300' }} _hover={{ bgColor: 'gray.300' }}

View File

@ -119,7 +119,7 @@ export const StepNodesList = ({
<Stack <Stack
spacing={1} spacing={1}
transition="none" transition="none"
pointerEvents={isReadOnly ? 'none' : 'auto'} pointerEvents={isReadOnly || isStartBlock ? 'none' : 'auto'}
> >
<Flex <Flex
ref={handlePushElementRef(0)} ref={handlePushElementRef(0)}