Skip to content

Commit 074f577

Browse files
committed
prevent unsaved change errors from being thrown after refreshing the block
1 parent ce5fd3f commit 074f577

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/blocks/pricing-table/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,17 @@ export const settings = {
7777

7878
// Reload when changes are made to access plans.
7979
$( document ).one( 'llms-access-plans-updated', function() {
80+
81+
// Replacing the block with a duplicate of itself so we can reload the block from the server.
8082
dispatch( 'core/editor' ).replaceBlock( props.clientId, createBlock( name ) );
83+
84+
// This will save the updates to the post content that appear as a result of the replacement.
85+
// Since I can't seem to figure out how to prevent the change from being triggered we have to duplicate a save.
86+
// which is gross. I know it's gross. It works though....
87+
setTimeout( function() {
88+
dispatch( 'core/editor' ).savePost();
89+
}, 500 );
90+
8191
} );
8292

8393
return (

0 commit comments

Comments
 (0)