Skip to content

Custom padding does not work without custom-unit theme support #27829

Closed

Description

@carolinan

Describe the bug
This may be a known issue but I could not find information about it when searching.
It is the first time I encounter the problem.

I was attempting to remove add_theme_support from my (fse) theme and replace it with the theme.json equivalent.
I replaced the custom spacing theme support with

"spacing": {
	"customPadding": true
},

and everything worked as expected.

But then I removed add_theme_support( 'custom-units' ); and the editor setting for custom padding stopped working.

Console JS error:

react-dom.production.min.js:125 TypeError: c.map is not a function
    at Cn (index.js?ver=03a17f333e4ad03901f675c7a322242c:9)
    at we (react-dom.production.min.js:84)
    at zj (react-dom.production.min.js:226)
    at Th (react-dom.production.min.js:152)
    at tj (react-dom.production.min.js:152)
    at Te (react-dom.production.min.js:146)
    at react-dom.production.min.js:61
    at unstable_runWithPriority (react.production.min.js:25)
    at Da (react-dom.production.min.js:60)
    at Pg (react-dom.production.min.js:61)

Also tested with TT1 Blocks.

To reproduce
Steps to reproduce the behavior:

  1. Activate a theme that has support for custom padding, like TT1 blocks.
  2. In the post editor, add a cover block and adjust the custom padding. Save.
  3. Remove the add_theme_support( 'custom-units' ); If using TT1 Blocks, this is on line 227 in functions.php.
  4. In the post editor, select the cover block or refresh the page. See that the cover block errors with "This block has encountered an error..."
  5. Add a second cover block. See that this cover block also errors.

Expected behavior
I expect the setting to work, even if only the default px values would be available.
If the custom padding requires the custom-unit, then it should not rely on the custom-unit theme support?

Editor version (please complete the following information):
WordPress version: 5.6
Gutenberg 9.6. rc-1 current master (last update e6f43ca)

Desktop (please complete the following information):
OS: Windows 10
Browser Chrome Version 87.0.4280.88

Activity

  1. added
    [Type] Help Request
    [Type] Bug
    on Dec 19, 2020
  2. carolinan commented on Jan 29, 2021

    @carolinan
    ContributorAuthor

    I want to add that this is not unique to full site editing themes. If I remove the add_theme_support( 'custom-units' );
    from Twenty Twenty-One then #28548 no longer works.

  3. oandregal commented on Jan 29, 2021

    @oandregal
    Member

    I used TwentyTwentyOne for testing and can repro: custom-spacing doesn't work without custom-units. I'm not sure how they are supposed to work together, but I presume what Carolina suggested (use px) is fine.

    cc @ItsJonQ what do you think of this?

  4. ItsJonQ commented on Jan 29, 2021

    @ItsJonQ

    Thanks for the heads up @carolinan + @nosolosw ! I just created a PR with a fix

  5. added
    [Status] In Progress
    on Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Status] In Progress[Type] Bug[Type] Help Request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions