Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cover: Fix undo trap #36807

Merged
merged 1 commit into from
Nov 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/block-library/src/cover/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ function CoverEdit( {
setAttributes,
setOverlayColor,
toggleSelection,
markNextChangeAsNotPersistent,
} ) {
const {
contentPosition,
Expand Down Expand Up @@ -391,6 +392,8 @@ function CoverEdit( {
);

useEffect( () => {
// This side-effect should not create an undo level.
markNextChangeAsNotPersistent();
setAttributes( { isDark: isCoverDark } );
}, [ isCoverDark ] );

Expand Down Expand Up @@ -770,10 +773,14 @@ function CoverEdit( {

export default compose( [
withDispatch( ( dispatch ) => {
const { toggleSelection } = dispatch( blockEditorStore );
const {
toggleSelection,
__unstableMarkNextChangeAsNotPersistent,
} = dispatch( blockEditorStore );

return {
toggleSelection,
markNextChangeAsNotPersistent: __unstableMarkNextChangeAsNotPersistent,
};
} ),
withColors( { overlayColor: 'background-color' } ),
Expand Down