Skip to content

Commit 060a44e

Browse files
authored
Merge pull request #258 from gocodebox/dev
Release 2.6.1
2 parents 0b13f5d + c7690d0 commit 060a44e

File tree

7 files changed

+35
-41
lines changed

7 files changed

+35
-41
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
LifterLMS Blocks Changelog
22
==========================
33

4+
v2.6.1 - 2025-08-18
5+
-------------------
6+
7+
##### Bug Fixes
8+
9+
+ Avoid unsaved changes warning with the course instructors block.
10+
11+
412
v2.6.0 - 2025-07-17
513
-------------------
614

includes/blocks/class-llms-blocks-instructors-block.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ public function get_attributes() {
7575
return array_merge(
7676
parent::get_attributes(),
7777
array(
78-
'post_id' => array(
79-
'type' => 'integer',
80-
'default' => 0,
81-
),
82-
'_refresh' => array(
78+
'post_id' => array(
8379
'type' => 'integer',
8480
'default' => 0,
8581
),

lifterlms-blocks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Plugin Name: LifterLMS Blocks
1212
* Plugin URI: https://github.com/gocodebox/lifterlms-blocks
1313
* Description: WordPress Editor (Gutenberg) blocks for LifterLMS.
14-
* Version: 2.6.0
14+
* Version: 2.6.1
1515
* Author: LifterLMS
1616
* Author URI: https://lifterlms.com/
1717
* Text Domain: lifterlms
@@ -27,7 +27,7 @@
2727

2828
// Define Constants.
2929
if ( ! defined( 'LLMS_BLOCKS_VERSION' ) ) {
30-
define( 'LLMS_BLOCKS_VERSION', '2.6.0' );
30+
define( 'LLMS_BLOCKS_VERSION', '2.6.1' );
3131
}
3232

3333
/**

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lifterlms-blocks",
3-
"version": "2.6.0",
3+
"version": "2.6.1",
44
"description": "blocks",
55
"author": "LifterLMS",
66
"homepage": "https://lifterlms.com/",

src/js/blocks/instructors/edit.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,23 @@ class InstructorsEdit extends Component {
3030

3131
this.state = {
3232
instructors: this.props.instructors,
33+
// Used to force a remount of <ServerSideRender /> after a save finishes.
34+
ssrNonce: 0,
3335
};
3436
}
3537

38+
/**
39+
* When a save transitions from "saving" -> "not saving", bump the nonce
40+
* so the SSR component remounts and refetches fresh HTML.
41+
*
42+
* @param {Object} prevProps
43+
*/
44+
componentDidUpdate( prevProps ) {
45+
if ( prevProps.isSavingPost && ! this.props.isSavingPost ) {
46+
this.setState( { ssrNonce: Date.now() } );
47+
}
48+
}
49+
3650
/**
3751
* Render component
3852
*
@@ -42,15 +56,15 @@ class InstructorsEdit extends Component {
4256
*/
4357
render = () => {
4458
const { name, attributes, post_id } = this.props; // eslint-disable-line camelcase
59+
const { ssrNonce } = this.state;
4560

4661
return (
4762
<Fragment>
4863
<ServerSideRender
64+
key={ ssrNonce } // remount -> refetch on save complete
4965
block={ name }
5066
attributes={ attributes }
51-
urlQueryArgs={ {
52-
post_id,
53-
} }
67+
urlQueryArgs={ { post_id } }
5468
/>
5569
</Fragment>
5670
);
@@ -66,12 +80,13 @@ class InstructorsEdit extends Component {
6680
*/
6781
export default compose( [
6882
withSelect( ( select ) => {
69-
const { getEditedPostAttribute, getCurrentPostId } = select(
70-
'core/editor'
71-
);
83+
const { getEditedPostAttribute, getCurrentPostId, isSavingPost } =
84+
select( 'core/editor' );
85+
7286
return {
7387
post_id: getCurrentPostId(),
7488
instructors: getEditedPostAttribute( 'instructors' ),
89+
isSavingPost: isSavingPost(),
7590
};
7691
} ),
7792
] )( InstructorsEdit );

src/js/blocks/instructors/index.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,6 @@ export const name = 'llms/instructors';
3333
*/
3434
export const postTypes = [ 'course', 'llms_membership' ];
3535

36-
let wasSaving = false;
37-
38-
subscribe( () => {
39-
const isSaving = select( 'core/edit-post' ).isSavingMetaBoxes();
40-
41-
if ( wasSaving && ! isSaving ) {
42-
wasSaving = isSaving;
43-
44-
select( 'core/block-editor' )
45-
.getBlocks()
46-
.filter( ( b ) => b.name === name )
47-
.forEach( ( b ) =>
48-
dispatch( 'core/block-editor' ).updateBlockAttributes(
49-
b.clientId,
50-
{ _refresh: Date.now() }
51-
)
52-
);
53-
} else {
54-
wasSaving = isSaving;
55-
}
56-
} );
5736
/**
5837
* Register Block.
5938
*
@@ -75,10 +54,6 @@ export const settings = {
7554
post_id: {
7655
type: 'integer',
7756
default: 0,
78-
},
79-
_refresh: {
80-
type: 'integer',
81-
default: 0,
8257
}
8358
},
8459

0 commit comments

Comments
 (0)