Checking the "Mark as decorative" checkbox discards existing alternative text and caption #82002
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
[Block] ImageAffects the Image BlockAffects the Image Block[Status] In discussionUsed to indicate that an issue is in the process of being discussedUsed to indicate that an issue is in the process of being discussed[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
Description
The "Mark as decorative" checkbox in the image block discards any existing alternative text and caption text without warning, making it a destructive action. Checking a checkbox should not immediately discard user content without warning.
Step-by-step reproduction instructions
- Add an image, and then add a caption and some alt text.
- Check the "Mark as decorative" checkbox in the sidebar, then uncheck it.
- Your caption and alt text are not restored.
Screenshots, screen recording, code snippet
CleanShot.2026-08-24.at.17.11.54.mp4
Environment info
- Wordpress 7.1
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
[Block] ImageAffects the Image BlockAffects the Image Block[Status] In discussionUsed to indicate that an issue is in the process of being discussedUsed to indicate that an issue is in the process of being discussed[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Activity
cbirdsong commentedon Aug 24, 2026
Separate but related, it is also a bummer that clicking the caption button in the floating toolbar discards the caption:
CleanShot.2026-08-24.at.17.22.18.mp4
Maybe the solution to this could solve both?
Mamaduka commentedon Aug 25, 2026
I vaguely remember a related issue and discussion (unfortunately, can't find it now). The button works "Add/Remove Caption" and not as visual toggle, which can be the source of confusion. cc @ntsekouras
t-hamano commentedon Aug 25, 2026
This concern was discussed when this checkbox was actually implemented. #78064
I will quote some opinions regarding this.
cc @joedolson @jasmussen
jasmussen commentedon Aug 25, 2026
I've no strong opinion on what the solution is, and would therefore recommend the simplest path forward, and defer to Joe if he chimes in.
With that important deferral to stronger opinions, I nevertheless stand by what I said previously, which to unpack, can really boil down to this: undo works.
In that sense we could be reductive and apply this overall issue as mapping to numerous similar flows, where checking a box, toggle or selecting an option in a segmented control is "destructive" insofar as it unsets a previous setting. The thing is, so long as undo works, and even revision history, those two in combination arguably serve as the generic solution to all of such cases.
joedolson commentedon Aug 25, 2026
I think it would be helpful if unchecking the toggle restored any information removed by checking it, so that the data is restorable using the same mechanism that was used to remove it, as well as via undo.
But I think that the removal of the information is correct. If the image is marked as decorative, then it must not have any content information, so the only appropriate action is to remove that content.
cbirdsong commentedon Aug 25, 2026
Obviously it should not include any content in the front end while the checkbox is checked, but ideally it would store it somewhere so it can easily be restored later?
t-hamano commentedon Aug 26, 2026
I noticed that there are clear criteria in the design system for deciding whether to introduce a confirmation for destructive actions.
https://wordpress.github.io/gutenberg/?path=/docs/design-system-patterns-destructive-actions--docs
Even if the checkbox is checked, the alt text does not disappear immediately on the front end. Also, we can immediately restore the deleted alt text with Undo. Considering this, confirmation seems unnecessary.
joedolson commentedon Aug 27, 2026
I think that this situation could be a little different from what's documented in the design system. While those are true, I feel like they presume that the destruction consequences are obvious. In the case of an image with alternative text but no caption, there is no visible change, and a user does not know that this data has been removed. The fact that the alt textarea is removed from the view when the toggle is triggered doesn't actually inform the user that the text has been removed; it's common to conceal a field without removing the data from it.
Maybe switching the textarea to disabled and removing the content would make this more apparent?
t-hamano commentedon Aug 28, 2026
This is doable. In fact, this idea was initially implemented but was later disabled and removed during a review.
#78064 (comment)
joedolson commentedon Aug 28, 2026
And I think I probably would have agreed with that argument, but I hadn't really thought about the need to signal that this information has been removed.
t-hamano commentedon Sep 5, 2026
We cannot express that the disabled textarea is currently disabled due to an unintended bug. I plan to try this approach once the issue is resolved. See #82454
Mamaduka commentedon Sep 5, 2026
I think we can also leverage the
setAttributesarg as a callback method and locally store previous values, then restore them on toggle. A bit more code, but probably cleaner than doing it as a side effect.We're doing something similar in
packages/block-library/src/social-links/edit.jsx. It's only handled via an effect because blocks don't have direct access to the Styles toggle.ntsekouras commentedon Sep 5, 2026
Personally @jasmussen 's rationale resonates with me. I think it would be fine to leave as is. That said, if we want to have a minimum fallback for in-session toggles, @Mamaduka suggestion seems good:
For the DataForm path (Block fields experiment),
setValuealready gets the current attributes in item, so it can read the old values. and maybe a new attribute withrole: local(e.g. decorativeBackup) could work for both inspectors, so we'd have a single helper instead of a customEditfor the field.t-hamano commentedon Sep 5, 2026
+1. I don't have a strong opinion on whether to implement the minimum fallback.
joedolson commentedon Sep 8, 2026
+1. I also don't have a strong opinion; I can see arguments both for and against the minimum fallback.
My previous arguments are on the for side; and I think those are valid. It's useful for a user to be able to reverse an action from the same place that they made the change, and it might help with awareness.
On the other hand, it might give people the impression that they can reverse that action at any time - e.g., save their post, come back later, uncheck the box, and get the alt text back. E.g., that this is more of a "use alt text" toggle. Even that impression isn't all that harmful, though, because the information is still recoverable from revision history, if really needed.
ntsekouras commentedon Sep 9, 2026
Thanks all for the discussion! It seems there are no strong opinions either way and both approaches have some trade-offs, so I think it's fine to leave this as is. Closing for now, but we can reopen if more folks feel we need the fallback.