Skip to content
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

Fix: Alt and caption text written on images while the image was temporary is deleted. #16051

Merged

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Jun 7, 2019

Fixes: #12202, #16746

Currently, the image alt text written while the image is temporary (points to a blob URL) is deleted as soon as the upload finishes.

This PR fixes the problem.
Alt attribute is not set when the upload is complete if the current image is temporary and an alt already exists.

Description

How has this been tested?

(to make the upload slow I used chrome dev tools network throttling)
I added an image block, I pressed the upload button, while the image is uploading I wrote some alt text. I verified that the al text was persisted when the upload finished.
I repeated the same test but instead of adding an image block I drag&dropped an image directly to the editor.
I added an image I wrote some alt text. I drag & dropped another image to replace the current image, I waited for the upload to complete and I verified the alt text was removed.

@jorgefilipecosta jorgefilipecosta added [Type] Bug An existing feature does not function as intended [Block] Image Affects the Image Block labels Jun 7, 2019
@jorgefilipecosta jorgefilipecosta added the [Feature] Media Anything that impacts the experience of managing media label Jun 12, 2019
packages/block-library/src/image/edit.js Outdated Show resolved Hide resolved
const { id, url, alt } = this.props.attributes;
// If the current image is temporary but an alt text was meanwhile wrotten by the user,
// make sure the text is not overwritten.
if ( alt && isTemporaryImage( id, url ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also take care of the caption here so that this can also close #16746 .

@jorgefilipecosta jorgefilipecosta force-pushed the fix/upload-deletes-alt-written-during-image-upload branch from 86b3eea to f5a01f2 Compare July 26, 2019 18:34
@jorgefilipecosta jorgefilipecosta changed the title Fix: Alt text written on images while the image was temporary is deleted. Fix: Alt and caption text written on images while the image was temporary is deleted. Jul 26, 2019
@jorgefilipecosta
Copy link
Member Author

Hi @epiqueras, thank you for reviewing this PR! The PR was rebased and updated to also deal with the caption.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/upload-deletes-alt-written-during-image-upload branch from f5a01f2 to b5e62ef Compare July 26, 2019 19:07
@jorgefilipecosta jorgefilipecosta dismissed epiqueras’s stale review August 6, 2019 14:23

The suggestion was applied.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/upload-deletes-alt-written-during-image-upload branch from b5e62ef to b92780e Compare August 6, 2019 14:26
@jorgefilipecosta jorgefilipecosta merged commit c148164 into master Aug 6, 2019
@jorgefilipecosta jorgefilipecosta deleted the fix/upload-deletes-alt-written-during-image-upload branch August 6, 2019 16:15
@youknowriad youknowriad added this to the Gutenberg 6.3 milestone Aug 9, 2019
gziolo pushed a commit that referenced this pull request Aug 29, 2019
gziolo pushed a commit that referenced this pull request Aug 29, 2019
@mrfoxtalbot
Copy link

This issue had been solved but I am seeing it just cam back when using Gutenberg 8.3.0 (this is not happening with the current core version of the block editor only if the plugin is active). I was also able to reproduce this on a WordPress.com simple site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block [Feature] Media Anything that impacts the experience of managing media [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alt text entered during image upload is lost when image finishes uploading
4 participants