-
Notifications
You must be signed in to change notification settings - Fork 846
VideoPress Block: Retain alignment support #16651
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
Conversation
This is an automated check which relies on E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-16651 |
|
Not sure why the |
yansern
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solution is much more elegant! I've tested it on my sandbox and it is working fine!
|
Caution: This PR has changes that must be merged to WordPress.com |
jeherve
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests well for me.
|
Thanks Jan and Jeremy! |
|
@jeherve pointed me to the Fusion comment (thanks!): #16651 (comment) -- it did produce a WP.com patch after he forced it 🙂 |
|
r211514-wpcom |
…ic/jetpack into add/jetpack-lazy-images-package * 'add/jetpack-lazy-images-package' of github.com:Automattic/jetpack: (40 commits) Lodash: Revert to previous version (#16735) New class to handle async XML-RPC requests (#16674) Social Previews: Sidebar design updates (#16725) Update E2E locator for classic connection flow (#16708) Woo Services: update to use existing Jetpack plugin install tools (#16672) Admin Page: avoid blank dashboard when notice is not a string (#16721) Admin Page: update string still using old i18n format (#16722) Social Previews: Add sidebar UI (#16633) Fix recurring payments block disconnecting (sometimes) when existing article is reopened in block editor. (#16640) Connection Register: Add current user email to connection register request (#16712) Update versions to start 8.9 Release cycle (#16706) Donations block: Make currency and amounts editable (#16593) Update dependency @automattic/calypso-color-schemes to v2 Error Notice: removing HTML code, adjusting maximum width. (#16690) Update dependency swiper to v6 (#16587) Site Scan: Short-circuit update_threats_link() if Admin Bar is not present (#16677) Update vulnerable NPM packages (#16659) E2E Tests: Add Jetpack updater test (#16437) check for subdir site before rendering Ads.txt section (#16671) VideoPress Block: Retain alignment support (#16651) ...
The VideoPress block wraps around the `core/video` block. The `core/video` block sets the `align` `supports` field to `true` (rather than adding the attribute explicitly): https://github.com/WordPress/gutenberg/blob/6cce6e0fdbb27d496370d48305913523e3251ea1/packages/block-library/src/video/block.json#L66 The VideoPress block [inherits the `supports` field](https://github.com/Automattic/jetpack/blob/2ec6da0446c15fd0c87ac1c799c4075063db5598/extensions/blocks/videopress/editor.js#L158-L161) from the `core/video` block, but somehow in the process, the alignment support is lost -- that is issue #16158. It turns out that handling of that `align` `supports` field is implemented in https://github.com/WordPress/gutenberg/blob/6cce6e0fdbb27d496370d48305913523e3251ea1/packages/block-editor/src/hooks/align.js, mostly through a number of filters that 1. [add](https://github.com/WordPress/gutenberg/blob/6cce6e0fdbb27d496370d48305913523e3251ea1/packages/block-editor/src/hooks/align.js#L228-L232) the [`align` attribute](https://github.com/WordPress/gutenberg/blob/6cce6e0fdbb27d496370d48305913523e3251ea1/packages/block-editor/src/hooks/align.js#L80-L102) to the block 2. [inject](https://github.com/WordPress/gutenberg/blob/6cce6e0fdbb27d496370d48305913523e3251ea1/packages/block-editor/src/hooks/align.js#L243-L247) the [`align{left|right|center}` class name into the saved HTML](https://github.com/WordPress/gutenberg/blob/6cce6e0fdbb27d496370d48305913523e3251ea1/packages/block-editor/src/hooks/align.js#L200-L226). The reason for alignment support not carrying over to the VideoPress block is that we're [attaching](https://github.com/Automattic/jetpack/blob/2ec6da0446c15fd0c87ac1c799c4075063db5598/extensions/blocks/videopress/editor.js#L199) the VideoPress wrapper to the same filter that Gutenberg's [`addAttribute`]((https://github.com/WordPress/gutenberg/blob/6cce6e0fdbb27d496370d48305913523e3251ea1/packages/block-editor/src/hooks/align.js#L228-L232)) filter uses to automatically inject the `align` attribute -- they're just called in the wrong order.
The VideoPress block wraps around the
core/videoblock. Thecore/videoblock sets thealignsupportsfield totrue(rather than adding the attribute explicitly): https://github.com/WordPress/gutenberg/blob/6cce6e0fdbb27d496370d48305913523e3251ea1/packages/block-library/src/video/block.json#L66The VideoPress block inherits the
supportsfield from thecore/videoblock, but somehow in the process, the alignment support is lost -- that is issue #16158.It turns out that handling of that
alignsupportsfield is implemented in https://github.com/WordPress/gutenberg/blob/6cce6e0fdbb27d496370d48305913523e3251ea1/packages/block-editor/src/hooks/align.js, mostly through a number of filters thatalignattribute to the blockalign{left|right|center}class name into the saved HTML.The reason for alignment support not carrying over to the VideoPress block is that we're attaching the VideoPress wrapper to the same filter that Gutenberg's
addAttributefilter uses to automatically inject thealignattribute -- they're just called in the wrong order.Fixes #16158
Supersedes #16627
props @yansern for the original PR #16627 and underlying research (Automattic/wp-calypso#43252).
Changes proposed in this Pull Request:
This PR fixes the issue by assigning a higher priority to the VideoPress block's
blocks.registerBlockTypefilter -- arguably, our block-level modifications should run before the more generic modifiers that insert extra class names. Furthermore, this solution will also cover othersupportsfields that use the same mechanism (e.g.anchor) without requiring adding those attributes explicitly in the VideoPress block.Jetpack product discussion
N/A
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
Proposed changelog entry for your changes:
Fix VideoPress block alignment not respected in the block editor.