Skip to content

Fix state refreshing block editor modal when changing block name

Jaden DIEFENBAUGH requested to merge tc-modal-refresh-fix into master

This is a hotfix for #146 (closed) . The new state management stuff was updating the block editor modal each time something about the block changed (which makes sense). However when the new state stuff updated the modal's data, there is a brief period of time where the data supplied to the modal is undefined, which throws the modal off and causes it to bounce off/on. Now it won't update when the data is changed to undefined, and will instead wait until the data is valid.

This moment of undefined happens because unfortunately the names of the blocks are their main identifiers, so changing a name means recomputing block identifiers throughout the editor, which leads to a moment of time where the old identifier isn't found and so the data is undefined.

A side-effect of this is that the modal won't close naturally when the block is deleted using that big "Delete Block" button. I added a line to close the modal when they click this button so that it functions like normal.

Merge request reports