Skip to content

Commit

Permalink
Text patterns: fix undo after mouse move (#18533)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Nov 18, 2019
1 parent 9441c16 commit 6c95d81
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/block-editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,12 @@ export function automaticChangeStatus( state, action ) {
if ( state !== 'final' ) {
return state;
}

return;
// Undoing an automatic change should still be possible after mouse
// move.
case 'STOP_TYPING':
return state;
}

// Reset the state by default (for any action not handled).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ exports[`List should undo asterisk transform with backspace 1`] = `
<!-- /wp:paragraph -->"
`;
exports[`List should undo asterisk transform with backspace after mouse move 1`] = `
"<!-- wp:paragraph -->
<p>* </p>
<!-- /wp:paragraph -->"
`;
exports[`List should undo asterisk transform with backspace after selection changes 1`] = `
"<!-- wp:paragraph -->
<p>* </p>
Expand Down
9 changes: 9 additions & 0 deletions packages/e2e-tests/specs/editor/blocks/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ describe( 'List', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should undo asterisk transform with backspace after mouse move', async () => {
await clickBlockAppender();
await page.keyboard.type( '* ' );
await page.mouse.move( 0, 0, { steps: 10 } );
await page.keyboard.press( 'Backspace' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );

it( 'should undo asterisk transform with backspace after selection changes without requestIdleCallback', async () => {
await clickBlockAppender();
await page.evaluate( () => delete window.requestIdleCallback );
Expand Down

0 comments on commit 6c95d81

Please sign in to comment.