VideoPress: prevent false dirty state in Site Editor for legacy blocks#50256
VideoPress: prevent false dirty state in Site Editor for legacy blocks#50256shsajalchowdhury wants to merge 2 commits into
Conversation
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Jetpack plugin: No scheduled milestone found for this plugin. If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
jeherve
left a comment
There was a problem hiding this comment.
Thank you for your contribution.
We'll need to fix the changelog format before we can merge this.
|
Thanks @shsajalchowdhury! It looks like this fixes it for the site editor, but the post editor still shows it dirty. I believe the |
The componentDidUpdate lifecycle unconditionally called setAttributes with videoPressClassNames on every render when a preview was available. This marked the entity as dirty even when the value was identical, causing a persistent "Review 1 change" prompt in the Site Editor. Fix: Only dispatch setAttributes when the computed sandboxClassnames differs from the current videoPressClassNames attribute value. Fixes Automattic#48633
1c888dd to
b53dcaf
Compare
|
Hi @jeherve, thanks for the review! The changelog type was already corrected from |
What
Fixes #48633
Why
When the Site Editor loads a template containing legacy
wp:videoblocks with VideoPress attributes (guid,videoPressClassNames), the editor persistently shows "Review 1 change" on every reload — even after saving. The dirty state is caused entirely client-side with no actual content change.Root Cause
In
componentDidUpdate, the VideoPress edit component unconditionally callssetAttributes( { videoPressClassNames: sandboxClassnames } )whenever a preview is available. Even when the computed value is byte-for-byte identical to the existing attribute, thesetAttributesdispatch marks the block (and by extension the template entity) as dirty.How
Added a strict equality check: only call
setAttributeswhensandboxClassnamesdiffers from the currentattributes.videoPressClassNamesvalue. This prevents the unnecessary dispatch that flags the entity as dirty.Testing Instructions
Changelog
Does this pull request change what data or activity we track or use?
No. This change only adds a strict equality check before calling setAttributes — no data collection or tracking changes.
Testing instructions
<!-- wp:video {"id":1,"guid":"239t8ryY","videoPressClassNames":"wp-block-embed is-type-video is-provider-videopress"} --><figure class="wp-block-video wp-block-embed is-type-video is-provider-videopress"><div class="wp-block-embed__wrapper">https://videopress.com/v/239t8ryY?resizeToParent=true&cover=true&preloadContent=metadata&useAverageColor=true</div></figure><!-- /wp:video -->