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

onLoad content is added to undo stack #89

Open
mirka opened this issue Nov 17, 2021 · 1 comment
Open

onLoad content is added to undo stack #89

mirka opened this issue Nov 17, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@mirka
Copy link
Member

mirka commented Nov 17, 2021

Despite the intent of this code to prevent initial onLoad content from being added to the undo stack, it does get added and is undoable:

// Set initial content, if we have any, but only if there is no existing data in the editor (from elsewhere)
useEffect( () => {
const loadData = async () => {
const initialContent = await getInitialContent( settings, onLoad );
if ( initialContent.length > 0 && ( ! blocks || blocks.length === 0 ) ) {
updateBlocksWithoutUndo( initialContent );
}
};
loadData();
}, [] );

(This behavior was fixed for undo in collab mode #68, but is not yet fixed for the non-collab case.)

Steps to reproduce

For convenience, here's a branch with a Storybook story for onLoad and a failing UI integration test: https://github.com/Automattic/isolated-block-editor/tree/test/onload-undo

  1. Load an iso-editor with some onLoad content.
  2. Once the initial content loads, the Undo button is active.
  3. When you trigger an undo, you can wipe out the initial content.

Expected behavior

The initial onLoad content is not undoable.

@mirka mirka added the bug Something isn't working label Nov 17, 2021
@johngodley
Copy link
Member

Ah, I've been meaning to look into this - thanks for debugging it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants