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

Gutenberg: Featured Image not updated when edited on Media Modal #29829

Closed
mmtr opened this issue Jan 1, 2019 · 3 comments · Fixed by #31761
Closed

Gutenberg: Featured Image not updated when edited on Media Modal #29829

mmtr opened this issue Jan 1, 2019 · 3 comments · Fixed by #31761
Assignees
Labels
[Goal] Gutenberg Working towards full integration with Gutenberg [Type] Bug When a feature is broken and / or not performing as intended

Comments

@mmtr
Copy link
Member

mmtr commented Jan 1, 2019

Steps to reproduce

  1. Open the block editor at /block-editor and select a site under a paid plan (free plans don't allow to edit images in the Media Modal).
  2. Set a featured image.
  3. Click on the featured media so the Medial Modal is opened.
  4. Select the current featured image and click on the Edit button.
  5. Push the "Edit Image" button and apply some changes to the image (e.g. flip it).
  6. Click on the Done button and insert the modified image.

What I expected

The featured image should display the modified image.

What happened instead

The featured image displays the previous image.

Context / Source

Related: #29791.

@mmtr mmtr added [Type] Bug When a feature is broken and / or not performing as intended [Pri] Normal Schedule for the next available opportuinity. [Goal] Gutenberg Working towards full integration with Gutenberg labels Jan 1, 2019
@mmtr mmtr assigned mmtr and unassigned mmtr Jan 1, 2019
@gwwar gwwar self-assigned this Mar 12, 2019
@gwwar gwwar changed the title Gutenlypso: Featured Image not updated when edited on Media Modal Gutenberg: Featured Image not updated when edited on Media Modal Mar 12, 2019
@gwwar gwwar removed the [Pri] Normal Schedule for the next available opportuinity. label Mar 12, 2019
@gwwar gwwar removed their assignment Mar 12, 2019
@obenland
Copy link
Member

I was able to reproduce that. It appears it doesn't update the view of that picture, it displays correctly after a reload

@Copons Copons self-assigned this Mar 25, 2019
@Copons
Copy link
Contributor

Copons commented Mar 25, 2019

Calypso Media Modal successfully updates the media URL (therefore it shows correct once reloaded), but there is no handling in the iframe bridge.

Unfortunately it's easier said than done, as the post object in the Block Editor uses only the media ID for the featured_media attribute, which does not change when the media is edited.

I'm trying to figure out if there is a way to force the featured image component to reselect the media with the new URL. 🤔

@mmtr
Copy link
Member Author

mmtr commented Mar 26, 2019

In #29820, we solved a similar problem with Simple Payments. We refactored the logic in order to use multiple attributes (ID, URL, etc) as source of truth of the product images instead of just the ID, so we can specifically change the URL of the image.

That approach is a bit harder to replicate here since it will require a change in core.

Another option we can try is to invalidate somehow the media object stored on the state, so the PostFeaturedImage component will retrieve again the data from the API if we toggle quickly the ID:

editPost( { featured_media: 0 } ); 
// Invalidate here the cached featured image so next call 
// will retrieve most recent data from API.
editPost( { featured_media: image.id } );

Maybe this shouldInvalidate function can help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Goal] Gutenberg Working towards full integration with Gutenberg [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants