Skip to content

Commit

Permalink
Only update gallery flag if fetch result is explicitly boolean
Browse files Browse the repository at this point in the history
This adds the flag to the destructuring of the fetch callback (so it is
not binding to the stale closure value), and also conditionally updates
the global only if the type is explicitly boolean. This avoids a
scenario in which updates to other editor settings which omit the
gallery flag property result in the global value being overwritten with
`undefined`.
  • Loading branch information
mkevins committed Nov 24, 2021
1 parent 0885b7a commit 73f556b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/editor/src/components/provider/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ class NativeEditorProvider extends Component {
}

componentDidMount() {
const {
capabilities,
locale,
updateSettings,
galleryWithImageBlocks,
} = this.props;
const { capabilities, locale, updateSettings } = this.props;

updateSettings( {
...capabilities,
Expand Down Expand Up @@ -149,8 +144,10 @@ class NativeEditorProvider extends Component {
);

this.subscriptionParentUpdateEditorSettings = subscribeUpdateEditorSettings(
( editorSettings ) => {
window.wp.galleryBlockV2Enabled = galleryWithImageBlocks;
( { galleryWithImageBlocks, ...editorSettings } ) => {
if ( typeof galleryWithImageBlocks === 'boolean' ) {
window.wp.galleryBlockV2Enabled = galleryWithImageBlocks;
}
updateSettings( this.getThemeColors( editorSettings ) );
}
);
Expand Down

0 comments on commit 73f556b

Please sign in to comment.