-
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
Image: Fix resetting behaviour for alt image text #56809
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
|
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.
This change makes sense to me and it fixes the issue!
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.
Thanks for the reviews, folks! I'll leave this open overnight and if there's no objections, will merge it in tomorrow 🙂 |
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.
Good catch! Thanks for the ping! Looks good to me :)
Thanks for merging, Alex! 🙂 |
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
TextareaControl
component 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
resetAll
behaviour. 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 thesizeSlug
attribute. In any case, that can be explored separately if need be.How?
alt
to the list of properties cleared byresetAll
hasValue
check to see ifalt
is truthy (as both an empty string andundefined
are valid empty states)TextareaControl
for its controlled value, so that a cleared outalt
text field is reflected in the UIResolutionTool
if there are available size optionsTesting Instructions
This should hopefully be fairly straightforward to test with TwentyTwentyFour:
Alternative text
button 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