Image: Fix resetting behaviour for alt image text#56809
Merged
Conversation
|
Size Change: +7 B (0%) Total Size: 1.72 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 22c851a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7109960530
|
tellthemachines
approved these changes
Dec 6, 2023
Contributor
tellthemachines
left a comment
There was a problem hiding this comment.
This change makes sense to me and it fixes the issue!
Contributor
Author
|
Thanks for the reviews, folks! I'll leave this open overnight and if there's no objections, will merge it in tomorrow 🙂 |
ajlende
approved these changes
Dec 6, 2023
Contributor
ajlende
left a comment
There was a problem hiding this comment.
Good catch! Thanks for the ping! Looks good to me :)
Contributor
Author
|
Thanks for merging, Alex! 🙂 |
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.
What?
Fix resetting behaviour for the alt image text field in the Image block, when accessed via the tools panel menu. I think the logic was previously updated in #51545, so might want to double check with @ajlende if this approach looks okay.
Why?
I noticed that if you go to reset the alt image text it doesn't appear to immediately update the text area control. This appears to be because the
TextareaControlcomponent expects a string. Additionally, when going to "reset all", the alt text wasn't being cleared out.I've also added a check before rendering the resolution controls, as the "Resolution" menu item was appearing in the tools panel menu when it shouldn't.
Note
I noticed that the Resolution item will sometimes appear to have a value when you don't think it should, and also isn't properly covered by the
resetAllbehaviour. I haven't handled those issues in this PR, and I don't think this PR makes any difference to them — to fix those, I think something would likely need to be done using the imageDefaultSize value so that resetting would reset back to that value perhaps instead of just clearing out thesizeSlugattribute. In any case, that can be explored separately if need be.How?
altto the list of properties cleared byresetAllhasValuecheck to see ifaltis truthy (as both an empty string andundefinedare valid empty states)TextareaControlfor its controlled value, so that a cleared outalttext field is reflected in the UIResolutionToolif there are available size optionsTesting Instructions
This should hopefully be fairly straightforward to test with TwentyTwentyFour:
Alternative textbutton in the menu should clear the fieldReset all, and it should clear the field againScreenshots or screencast
Before
2023-12-06.14.46.17.mp4
After
2023-12-06.14.49.42.mp4