Make WordPress Core

Opened 7 weeks ago

Closed 7 weeks ago

#64195 closed defect (bug) (fixed)

Theme JSON: Fix filtering of default presets at block level

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

Description

This ticket tracks the backport of PHP files for the following Gutenberg updates:

https://github.com/WordPress/gutenberg/pull/72916

These updates include a fix and additional unit tests for a bug where default presets were merged incorrectly when defaults were disabled at the block level. The bug resulted in missing presets in the settings and UI.

Further background and context is available within the original issue:

https://github.com/WordPress/gutenberg/issues/72810

Change History (7)

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


7 weeks ago
#1

  • Keywords has-patch has-unit-tests added

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

This PR brings the changes from the following Gutenberg PRs to core:

https://github.com/WordPress/gutenberg/pull/72916

### Description

Prevents an issue where block level presets do not work correctly when:

  • Default presets are disabled
  • Slug matches the default preset

The result is missing presets in the settings and editor UI.

### Testing

For each theme.json example config below:

  1. Ensure default presets for the feature being testing is on at the global level
  2. Add the block level preset config to your theme.json file
  3. Confirm in the editor the expected presets are available generally and at the block level

### Duotone

In the image block, only the "Dark grayscale" duotone preset should be available

{
	"version": 3,
	"appearanceTools": true,
	"settings": {
		"blocks":{
			"core/image": {
				"color": {
					"defaultDuotone": false,
					"duotone": [
						{
							"name": "Dark grayscale",
							"colors": [ "#000000", "#7f7f7f" ],
							"slug": "dark-grayscale"
						}
					]
				}
			}
		}
	}
}

### Shadow

In the image block, only the "Natural" shadow preset should be available

{
	"version": 3,
	"settings": {
		"appearanceTools": true,
		"blocks":{
			"core/image": {
				"shadow": {
					"defaultPresets": false,
					"presets": [
						{
							"name": "Natural",
							"slug": "natural",
							"shadow": "6px 6px 9px rgba(0, 0, 0, 0.2)"
						}
					]
				}
			}
		}
	}
}

### Font Size

In the Paragraph block, only the "Small" duotone preset should be available

{
	"version": 3,
	"settings": {
		"appearanceTools": true,
		"blocks":{
			"core/paragraph": {
				"typography": {
					"defaultFontSizes": false,
					"fontSizes": [
						{
							"name": "Small",
							"slug": "small",
							"size": "13px"
						}
					]
				}
			}
		}
	}
}

## Screenshots or screencast

BeforeAfter
https://github.com/user-attachments/assets/ce72aed1-0f73-4cbe-86b3-4b6e7d61ed85 https://github.com/user-attachments/assets/6a925b8b-232d-434e-b463-2a166f309cdf

#2 @wildworks
7 weeks ago

  • Keywords commit added

The Gutenberg PR has been approved by two reviewers, and I believe it's ready for committing.

#3 @wildworks
7 weeks ago

@aaronrobertshaw, If you have the bandwidth, I would appreciate it if you could commit the pull request before the RC1 release next week.

#4 @aaronrobertshaw
7 weeks ago

@wildworks I've only just got this notification. I can try and get this merged tomorrow morning hopefully before the RC is cut but I've only followed along on a few commits way back at the start of the year. So I'll need some help

#5 @wildworks
7 weeks ago

@aaronrobertshaw I've recently started making commits myself, so it's okay if I make the commit on your behalf. In return, I would appreciate it if you could review whether I've written the commit message correctly. Are the title and description accurate in the following commit message?

Editor: Fix handling of default presets at block level in theme.json

Fix an issue where block-level presets do not work correctly when default presets are disabled and the slug matches a default preset.

Props aaronrobertshaw, bph, ramonopoly, wildworks.
Fixes #64195.

#6 @aaronrobertshaw
7 weeks ago

Thanks @wildworks. That commit message looks good to me.

I'll get up to speed on the core commit process again ready for the next one.

#7 @wildworks
7 weeks ago

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

In 61190:

Editor: Fix handling of default presets at block level in theme.json

Fix an issue where block-level presets do not work correctly when default presets are disabled and the slug matches a default preset.

Props aaronrobertshaw, bph, ramonopoly, wildworks.
Fixes #64195.

Note: See TracTickets for help on using tickets.