Skip to content

Commit

Permalink
Mark change in attributes when gallery mounts as not persistant
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Oct 22, 2020
1 parent 55bf7ec commit 3a1578d
Showing 1 changed file with 5 additions and 1 deletion.
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 3a1578d

Please sign in to comment.