Skip to content

Videopress Block: Fix video width and lack of alignment classes#18006

Merged
aaronrobertshaw merged 9 commits into
masterfrom
fix/videopress-width
Jan 18, 2021
Merged

Videopress Block: Fix video width and lack of alignment classes#18006
aaronrobertshaw merged 9 commits into
masterfrom
fix/videopress-width

Conversation

@aaronrobertshaw
Copy link
Copy Markdown
Contributor

@aaronrobertshaw aaronrobertshaw commented Dec 8, 2020

Fixes Automattic/wp-calypso#46889
Fixes #17925

VideoPress block on WordPress.com doesn't get the alignment CSS classes applied to it on save. This leads to the video appearing to be different widths in editor vs frontend.

Changes proposed in this Pull Request:

  • Update application of CSS class names it to pick up the alignment CSS classes.
  • Fix block attributes to prevent block validation errors that were occurring in production
  • Move setting of classNames attribute out of the render() function to avoid UnsavedChangesWarning error.
  • Add deprecation for older blocks that were missing alignment classes or didn't get classNames saved due to bug.

Does this pull request change what data or activity we track or use?

No.

Unit test for attribute migrations

  1. Run yarn test-extensions
  2. Confirm extensions/blocks/videopress/test/index.js ran successfully.

Testing instructions - Local:

  1. Using master branch, start up local Jetpack site with sufficient plan to upload videos to videopress
  2. Add a video block to a post and upload a video
  3. Set it's alignment to wide and add a custom CSS class name via sidebar > advanced controls
  4. Save post and view on frontend. (Should be missing alignwide CSS class)
  5. Reload post in the editor, the block's will be invalid due to current bugs.
  6. Checkout this PR and rebuild Jetpack
  7. With dev tools console open, reload the editor and confirm no errors and the block deprecation is successfully applied
  8. Save the post and reload the frontend.
  9. Confirm the block displays with wide alignment

Testing instructions - Sandbox:

  1. Apply this PR branch and test VideoPress block functions correctly locally.
  2. On a sandboxed site with a sufficient plan, add a video to a post, set its alignment to "wide", then save.
  3. Confirm on the frontend that the video's block does not contain the alignwide CSS class.
  4. Apply this PR's associated diff ( D53903-code ) or use a8c-wp-env and sync Jetpack to your sandbox.
  5. Reload the editor for your sandboxed site and confirm the block is still valid.
  6. Change the block's alignment to "full" and save post.
  7. Switch to the frontend, reload and confirm the video block has the alignfull CSS class.

Screenshots

Wide Align - Before Wide Align - After
Screen Shot 2020-12-08 at 6 32 41 pm Screen Shot 2020-12-08 at 6 33 42 pm

Proposed changelog entry for your changes:

  • Fixes missing alignment classes on VideoPress block.
  • Fixes VideoPress block validation errors

@aaronrobertshaw aaronrobertshaw added Bug When a feature is broken and / or not performing as intended [Feature] VideoPress A feature to help you upload and insert videos on your site. [Status] Needs Team Review Obsolete. Use Needs Review instead. labels Dec 8, 2020
@aaronrobertshaw aaronrobertshaw self-assigned this Dec 8, 2020
@matticbot
Copy link
Copy Markdown
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello aaronrobertshaw! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D53903-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

@jetpackbot
Copy link
Copy Markdown
Collaborator

jetpackbot commented Dec 8, 2020

Scheduled Jetpack release: February 2, 2021.
Scheduled code freeze: January 25, 2021

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Generated by 🚫 dangerJS against bd70276

@aaronrobertshaw aaronrobertshaw changed the title [WIP] Videopress Block: Fix video width and lack of alignment classes Videopress Block: Fix video width and lack of alignment classes Dec 8, 2020
@glendaviesnz
Copy link
Copy Markdown
Contributor

I think we might not be able to use useBlockProps as it won't be supported by all the versions of the editor that jetpack supports - looks like it was only renamed and stabalised 2 months ago - WordPress/gutenberg#25642

@apeatling apeatling requested review from a team and apeatling December 10, 2020 18:40
Copy link
Copy Markdown
Contributor

@apeatling apeatling left a comment

Choose a reason for hiding this comment

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

We chatted about this, but I think you could check for the presence of useblockProps and fall back to manual if not present. Or go with manual until Jetpack catches up to this.

@roundhill
Copy link
Copy Markdown
Contributor

Stumbled across this PR, thanks for fixing @aaronrobertshaw 😄

@aaronrobertshaw
Copy link
Copy Markdown
Contributor Author

This has been updated to check for useBlockProps as well as being rebased.

I've tested this using the latest Gutenberg release and v9.1.1 just prior to when commit WordPress/gutenberg#25642 stabilised the block API involving useBlockProps in v9.2.0

@apeatling apeatling self-requested a review December 14, 2020 17:35
apeatling
apeatling previously approved these changes Dec 14, 2020
@apeatling apeatling added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Team Review Obsolete. Use Needs Review instead. labels Dec 14, 2020
@apeatling apeatling requested a review from a team December 14, 2020 17:35
@jeherve jeherve added this to the 9.3 milestone Dec 15, 2020
Copy link
Copy Markdown
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

Since we're changing the saved markup of our blocks, we'll need to handle block deprecation to avoid block validation errors when editing existing posts. Could you add this?

@jeherve jeherve added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Dec 15, 2020
apeatling
apeatling previously approved these changes Dec 21, 2020
@kraftbj kraftbj removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Dec 21, 2020
@aaronrobertshaw
Copy link
Copy Markdown
Contributor Author

I've rebased this PR and updated it to address the issue where newer versions of Gutenberg caused all the deprecations to be invalid. Tested with WordPress 5.5.3 and 5.6 as well as latest Gutenberg.

The issue with the wp-block-video class being added via the blocks.getSaveContent.extraProps filter was solved using another filter targeting deprecated blocks and adjusting the results so that the original saved content for a deprecated block would be successfully matched.

If anyone has any suggestions as to a better approach, I'd be happy to hear them.

@aaronrobertshaw aaronrobertshaw added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jan 13, 2021
Comment thread extensions/blocks/videopress/deprecated/v2/index.js Outdated
@glendaviesnz
Copy link
Copy Markdown
Contributor

This tests well for me now, and the migrations run correctly for the previous versions.

aaronrobertshaw and others added 7 commits January 15, 2021 13:17
* Fixes missing alignment CSS classes
* Fixes deprecations after Gutenberg introduction of wp-block-video CSS class
* Fixes bug introduced in prior patch addressing aspect ratio classes
Improves the clarity of the attribute naming to distinguish what was `classNames` from `className`.
@jeherve jeherve force-pushed the fix/videopress-width branch from 00ee06d to 62a7598 Compare January 15, 2021 12:17
This shouldn't be necessary anymore, we now have that rule set for all the extensions at once.
Copy link
Copy Markdown
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This works well for me now; it should be good to merge!

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Jan 15, 2021
@aaronrobertshaw aaronrobertshaw merged commit bb1591a into master Jan 18, 2021
@aaronrobertshaw aaronrobertshaw deleted the fix/videopress-width branch January 18, 2021 04:44
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Jan 18, 2021
jeherve added a commit that referenced this pull request Jan 26, 2021
@jeherve
Copy link
Copy Markdown
Member

jeherve commented Feb 2, 2021

r220372-wpcom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug When a feature is broken and / or not performing as intended [Feature] VideoPress A feature to help you upload and insert videos on your site. Touches WP.com Files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VideoPress: Video blocks encounter errors when using VideoPress URL Video Block: Width setting doesn't work

9 participants