Make WordPress Core

Opened 7 months ago

Closed 5 months ago

Last modified 5 months ago

#60681 closed defect (bug) (fixed)

Elements: Fix application of element class name when attributes are filtered

Reported by: aaronrobertshaw's profile aaronrobertshaw Owned by: isabel_brison's profile isabel_brison
Milestone: 6.6 Priority: normal
Severity: normal Version: 6.5
Component: Editor Keywords: gutenberg-merge has-patch has-unit-tests
Focuses: Cc:

Description

This ticket tracks the backporting of PHP files for the following Gutenberg changes:

These changes fix a bug where if the block data was filtered via render_block_data the elements CSS class wouldn't be consistently applied breaking the feature.

The initial solution that was merged in Gutenberg via https://github.com/WordPress/gutenberg/pull/59533 caused a conflict in CSS classes that https://github.com/WordPress/gutenberg/pull/59535 addresses.

Change History (8)

This ticket was mentioned in PR #6214 on WordPress/wordpress-develop by @aaronrobertshaw.


7 months ago
#1

  • Keywords has-patch has-unit-tests added

Syncs the changes from https://github.com/WordPress/gutenberg/pull/59535.

These change update the elements block support filters such that the elements class name is only generated in a single location. This avoids conflicts between class names and makes the block support robust in the face of a block's data being filtered via other render_block_data filters.

To test:

Confirm https://github.com/WordPress/gutenberg/issues/59462 is still resolved

  1. Edit a post and add a paragraph
  2. Create a link with the paragraph
  3. Via the block inspector apply a link color to the paragraph
  4. Save and view the frontend confirming the correct link color is shown
  5. Confirm nested applications of the same element styles work correctly:

Create some nested blocks containing links

  1. Apply a set of element styles to the parent block
  2. Apply different styles to a child block
  3. Apply the first set of element styles to a grand-child block
  4. Confirm the correct display of element styles

Unit tests:

npm run test:php -- --filter Tests_Block_Supports_WpRenderElementsSupport
npm run test:php -- --filter Tests_Block_Supports_WpRenderElementsSupportStyles

Trac ticket: https://core.trac.wordpress.org/ticket/60681

@aaronrobertshaw commented on PR #6214:


7 months ago
#2

This PR is still only in a draft state as I have run out of time. Unfortunately, I'll be AFK until next week with limited bandwidth to push this across the line.

Anyone is welcome to pick this up, push to it, or create an alternate PR 🙏

#3 @jorbin
6 months ago

  • Milestone changed from Awaiting Review to 6.6

#5 @isabel_brison
5 months ago

  • Owner set to isabel_brison
  • Resolution set to fixed
  • Status changed from new to closed

In 58074:

Editor: Merge element style and classname generation to single filter.

Fixes element classnames not being output when block attributes are filtered with render_block_data.

Props aaronrobertshaw, isabel_brison, jorbin.
Fixes #60681.

@isabel_brison commented on PR #6214:


5 months ago
#6

Committed in r58074.

@aaronrobertshaw commented on PR #6214:


5 months ago
#7

@mukeshpanchal27 as these changes were already committed, I've created a follow-up PR to address the issues noted

#8 @isabel_brison
5 months ago

In 58090:

Editor: Fix coding standards and move deprecated function to correct file.

Follow-up to [58074], formats docblocks correctly and moves wp_render_elements_support to the deprecated file.

Props aaronrobertshaw, isabel_brison, mukesh27, spacedmonkey.
See #60681.

Note: See TracTickets for help on using tickets.