'Attach a function when deleting a gutenberg block

I create a column system in block gutenberg, I would like to launch a function when deleting a column (to resize the remaining columns). My custom block "Columns" is a block of type "InnerBlock" which contains children blocks "Column".

attributes: {
        widths: {
            type: 'object',
            default: {
                lg: [ 6, 6 ],
                md: [ 4, 4 ],
                sm: [ 2, 2 ]
            }
        },
    },
edit: ( props ) =>
    {
        const { replaceInnerBlocks } = useDispatch( 'core/block-editor' )

        const inner_blocks = useSelect( select => select( 'core/block-editor' ).getBlocks( props.clientId ) )

        let custom_block_props = useBlockProps()
            custom_block_props.className += ` custom-columns--edit vertical-${props.attributes.vertical_alignment} horizontal-${props.attributes.horizontal_alignment}`
        
        const innerBlocksProps = useInnerBlocksProps( custom_block_props, {
            orientation: 'horizontal',
            renderAppender: false,
            allowedBlocks: [ 'danka/column' ],
            template: [
                [ 'danka/column' ],
                [ 'danka/column' ]
            ]
        } )
    }

I can’t find a solution that could solve my problem...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source