wordpress-mobile / gutenberg-mobile

Mobile version of Gutenberg - native iOS and Android
GNU General Public License v2.0
253 stars 56 forks source link

VideoPress v5: Plays inline setting not saving for Atomic sites w/o VideoPress #6671

Open SiobhyB opened 7 months ago

SiobhyB commented 7 months ago

Describe the bug

The plays inline setting is not working in the Video block for Atomic sites w/o VideoPress enabled. As part of his report here, @fluiddot suggested the following workaround as a solution:

diff --git forkSrcPrefix/projects/plugins/jetpack/extensions/blocks/videopress/save.js forkDstPrefix/projects/plugins/jetpack/extensions/blocks/videopress/save.js
index 2c6b81eae8cd005e7b83036f217a93dc3438d54f..6bdff0d8fc893f8a0710b9406fbb9b0ab4b139a9 100644
--- forkSrcPrefix/projects/plugins/jetpack/extensions/blocks/videopress/save.js
+++ forkDstPrefix/projects/plugins/jetpack/extensions/blocks/videopress/save.js
@@ -42,7 +42,15 @@ const VideoPressSave = CoreVideoSave => props => {
         * @see https://github.com/WordPress/gutenberg/blob/c5f9bd88125282a0c35f887cc8d835f065893112/packages/editor/src/hooks/generated-class-name.js#L42
         * @see https://github.com/Automattic/wp-calypso/pull/30546#issuecomment-463637946
         */
-       return CoreVideoSave( props );
+
+       // Rename `playsinline` to `playsInline` to conform the block schema of core Video block.
+       const { playsinline: videoPressPlayinline, ...restAttributes } = props.attributes;
+       const coreVideoAttributes = { ...restAttributes, playsInline: playsinline };
+
+       return CoreVideoSave( {
+           ...props,
+           attributes: coreVideoAttributes,
+       } );
    }

    const url = getVideoPressUrl( guid, {

To Reproduce

Steps to reproduce the behavior:

  1. Set up an Atomic site and disable VideoPress (this can be done via the Jetpack admin panel).
  2. In the app, navigate to the site's post editor.
  3. Add a video block and upload any video to it.
  4. Open the block's settings panel and toggle the "plays inline" setting on.
  5. Save your changes and exit the post.
  6. Navigate to the post editor containing the video on the web.
  7. Notice that "plays inline" is not toggled on when viewing the settings on the web.

Expected behavior

The setting should persist across platforms.

Additional context

It's worth highlighting that this isn't a recent regression. Prior to VideoPress v5 being implemented, the setting was broken in the app for all site types (ref: https://github.com/wordpress-mobile/gutenberg-mobile/issues/1721). It's now only broken for Atomic sites w/o VideoPress enabled.

SiobhyB commented 7 months ago

Note, the proposed workaround was implemented in https://github.com/Automattic/jetpack/pull/35981, but we needed to revert due to it causing a regression in Atomic sites w/VideoPress enabled on the web.