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

Record selection changes in history (undo) #17824

Merged
merged 4 commits into from
Nov 20, 2019

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Oct 7, 2019

Description

Same as #16428, but adjusted after #16932.

Stores selection in the undo reducer. The following gif shows the result after two times undo:

undo-selection

How has this been tested?

Screenshots

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

@ellatrix ellatrix force-pushed the try/blocks-selection-history-2 branch from 36c3145 to 1057917 Compare October 8, 2019 09:50
@ellatrix ellatrix marked this pull request as ready for review October 8, 2019 12:14
@ellatrix ellatrix added [Package] Block editor /packages/block-editor [Package] Editor /packages/editor [Package] Rich text /packages/rich-text [Feature] History History, undo, redo, revisions, autosave. labels Oct 8, 2019
@ellatrix ellatrix added this to the Gutenberg 6.7 milestone Oct 8, 2019
Copy link
Contributor

@epiqueras epiqueras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I just have one question, otherwise it looks perfect.

@@ -84,54 +141,121 @@ describe( 'undo', () => {
await pressKeyWithModifier( 'primary', 'z' ); // Undo 3rd paragraph text.

expect( await getEditedPostContent() ).toBe( thirdBlock );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a check before the first undo here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be enough to only test selection after undo right? After typing, we already know for sure where the selection is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After typing, we already know for sure where the selection is.

It wouldn't hurt to verify that it synced correctly.

@ellatrix
Copy link
Member Author

Unsure why one of the selection tests is failing. Need to have another look into it.

@ellatrix ellatrix modified the milestones: Gutenberg 6.7, Gutenberg 6.8 Oct 23, 2019
@ellatrix ellatrix force-pushed the try/blocks-selection-history-2 branch from 63de0ad to 6e47e7a Compare November 18, 2019 15:01
@ellatrix
Copy link
Member Author

Rebased the PR and fixed the e2e test failure (caused by a miscalculation). @epiqueras would you be up for having another look?

Copy link
Contributor

@epiqueras epiqueras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great.

Not a blocker, but I think we could do with some "multi-selection" test cases.

@ellatrix
Copy link
Member Author

Multi selection + undo/redo tests don't seem trivial to add since it doesn't seem to be fully working. It resets to a collapsed range. I think I'd prefer to merge this as is now, and polish the behaviour with follow up PRs. The PR in its current form is already many times better than the current behaviour in master.

@epiqueras
Copy link
Contributor

Sounds good.

@epiqueras epiqueras merged commit 6c4b5e5 into master Nov 20, 2019
@epiqueras epiqueras deleted the try/blocks-selection-history-2 branch November 20, 2019 17:09
@ellatrix
Copy link
Member Author

Thanks for the review @epiqueras!

@youknowriad
Copy link
Contributor

Did we check what issues can be closed with this. I think we might have a few of these.

@ellatrix
Copy link
Member Author

@youknowriad I only found #12327.

@youknowriad
Copy link
Contributor

Interesting, I'm pretty sure I saw issues about the caret not restored to the right position on undo. We'll find them in triage sessions anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] History History, undo, redo, revisions, autosave. [Package] Block editor /packages/block-editor [Package] Editor /packages/editor [Package] Rich text /packages/rich-text
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants