-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Media & Text Block: create undo history when media width is changed #46084
Merged
Conversation
This file contains 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
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: +4 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
Media & Text Block: create undo history when media width is changed
t-hamano
force-pushed
the
media-text/create-undo-resize
branch
from
November 26, 2022 03:58
d5c95bd
to
511b3ac
Compare
jorgefilipecosta
approved these changes
Dec 8, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes the bug in my tests 👍
15 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Block] Media & Text
Affects the Media & Text Block
Needs User Documentation
Needs new user documentation
[Package] Block library
/packages/block-library
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.
Fixes #45933
What?
This PR ensures that undo history is successfully created in the media text block when the media size is changed.
Why?
This block holds a temporary width as a state to prevent unnecessary updates of attributes. Then, when a resize operation is performed, there are two change events:
In the current implementation, when attirbutes are "committed", the state is also updated with the same value. However, the undo operation doesn'ot change the state. The value of state (the value before undo) is preferentially set, making it appear that the value has not changed.
gutenberg/packages/block-library/src/media-text/edit.js
Line 212 in 40aa5e6
gutenberg/packages/block-library/src/media-text/edit.js
Line 311 in 40aa5e6
When a width change is committed, we need to reset the state value to display the attribute value preferentially.
This is also the implementation seen in the spacer block.
Testing Instructions
Screenshots or screencast
542a43157a949ca78a33a0df3bfd9f29.mp4