Skip to content

Commit

Permalink
Fix gallery block undo issue (#26377)
Browse files Browse the repository at this point in the history
* Mark change in attributes when gallery mounts as not persistant

* Fix typo
  • Loading branch information
talldan committed Oct 27, 2020
1 parent d63edd8 commit 0c1a67e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/block-editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ export function __unstableSaveReusableBlock( id, updatedId ) {
}

/**
* Returns an action object used in signalling that the last block change should be marked explicitely as persistent.
* Returns an action object used in signalling that the last block change should be marked explicitly as persistent.
*
* @return {Object} Action object.
*/
Expand Down
6 changes: 5 additions & 1 deletion packages/block-library/src/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { MediaPlaceholder, InspectorControls } from '@wordpress/block-editor';
import { Platform, useEffect, useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';
import { withSelect } from '@wordpress/data';
import { useDispatch, withSelect } from '@wordpress/data';
import { withViewportMatch } from '@wordpress/viewport';

/**
Expand Down Expand Up @@ -85,6 +85,9 @@ function GalleryEdit( props ) {
} = attributes;
const [ selectedImage, setSelectedImage ] = useState();
const [ attachmentCaptions, setAttachmentCaptions ] = useState();
const { __unstableMarkNextChangeAsNotPersistent } = useDispatch(
'core/block-editor'
);

function setAttributes( newAttrs ) {
if ( newAttrs.ids ) {
Expand Down Expand Up @@ -305,6 +308,7 @@ function GalleryEdit( props ) {
// linkTo attribute must be saved so blocks don't break when changing
// image_default_link_type in options.php
if ( ! linkTo ) {
__unstableMarkNextChangeAsNotPersistent();
setAttributes( {
linkTo:
window?.wp?.media?.view?.settings?.defaultProps?.link ||
Expand Down

0 comments on commit 0c1a67e

Please sign in to comment.