Skip to content

Commit

Permalink
fix update blocks if position change
Browse files Browse the repository at this point in the history
  • Loading branch information
mxkae committed Jul 15, 2024
1 parent 6c2746b commit 0d27ee7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/block/timeline/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const Edit = props => {
const middleRef = useRef()
const branchRef = useRef()
const blockRef = useRef()
const isUpdating = useRef( false )
const [ middleTopPosition, setMiddleTopPosition ] = useState( { dot: 0, branch: 0 } )
const [ fillHeight, setFillHeight ] = useState( { verticalLine: 0, middle: 0 } )
const [ verticalLineMaxHeight, setVerticalLineMaxHeight ] = useState( 0 )
Expand Down Expand Up @@ -298,11 +299,18 @@ const Edit = props => {
if ( nextBlock && nextBlock.name === 'stackable/timeline' && props.attributes.timelineIsLast ) {
dispatch( 'core/block-editor' ).__unstableMarkNextChangeAsNotPersistent()
setAttributes( { timelineIsLast: false } )
} else if ( ! nextBlock || nextBlock.name !== 'stackable/timeline' ) {
isUpdating.current = true
} else if ( ( ! nextBlock || nextBlock.name !== 'stackable/timeline' ) && props.attributes.timelineIsLast ) {
dispatch( 'core/block-editor' ).__unstableMarkNextChangeAsNotPersistent()
setAttributes( { timelineIsLast: true } )
isUpdating.current = true
}
updateMaxHeight()
if ( isUpdating.current ) {
updateMaxHeight()
setTimeout( () => {
isUpdating.current = false
}, 300 )
}
}, [ nextBlock ] )

useEffect( () => {
Expand Down

0 comments on commit 0d27ee7

Please sign in to comment.