Try a generic undo handler#4959
Closed
youknowriad wants to merge 2 commits intotry/editable-input-onchangefrom
Closed
Try a generic undo handler#4959youknowriad wants to merge 2 commits intotry/editable-input-onchangefrom
youknowriad wants to merge 2 commits intotry/editable-input-onchangefrom
Conversation
21d490f to
b5764cd
Compare
ellatrix
reviewed
Feb 9, 2018
| partialRight( withHistory, { | ||
| resetTypes: [ 'SETUP_NEW_POST', 'SETUP_EDITOR' ], | ||
| shouldOverwriteState: ( previous, next ) => { | ||
| if ( previous.type !== next.type || previous.type !== 'UPDATE_BLOCK_ATTRIBUTES' ) { |
Member
There was a problem hiding this comment.
Do you think we could generalise this more? Say e.g. someone changes the post format to "link", but then immediate changes it back to "standard", I think we should avoid to create an undo level as well. Similarly we could have input fields outside block scope, which would still add records for each character change?
ellatrix
reviewed
Feb 9, 2018
| return false; | ||
| } | ||
|
|
||
| return areValuesEquivalent( previous.attributes[ previousAttributes[ 0 ] ], next.attributes[ nextAttributes[ 0 ] ] ); |
Member
There was a problem hiding this comment.
areValuesEquivalent sounds like an expensive calculation to execute on every action (an thus keystroke).
3 tasks
15fa35c to
efff741
Compare
Contributor
Author
|
Superseded by #4956 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The undo state shouldn’t be related to components at all and maybe have something like this:
Compare the redux dispatch action triggering a change with the previous dispatched action. If the two actions are similar: which could mean, they’re both
UPDATE_ATTRIBUTESof the same block and they both update the same attribute and the only difference between these two attributes is a single alphanumeric character (not space etc...), override the previous undo state.If the actions are different, create a new undo state.
This would be very generic