Skip to content

Site Editor breaks when no color, gradient or font-size is configured #31986

Closed

Description

@erikjoling

Description

When I try to disable colors, gradients or font-sizes I can't enter the Site Editor.

Step-by-step reproduction instructions

Disable through theme-support:

add_theme_support( 'editor-color-palette' );
add_theme_support( 'editor-gradient-presets' );
add_theme_support( 'editor-font-sizes' );

or disable through theme.json:

"settings": {
	"color": {
		"gradients": null,
		"palette": null
	},
	"typography": {
		"fontSizes": null
	}
}

Expected behaviour

Have the controls disabled and being able to enter the site-editor.

Actual behaviour

Have the controls disabled and not being able to enter the site-editor.

WordPress information

  • WordPress version: "5.7.2".
  • Gutenberg version: "10.6.1"
  • Are all plugins except Gutenberg deactivated? "Yes"
  • Are you using a default theme (e.g. Twenty Twenty-One)? "No"

Device information

  • Device: "Desktop"
  • Operating system: "Ubuntu 20"
  • Browser: "Firefox"

Activity

  1. carolinan commented on May 19, 2021

    @carolinan
    Contributor

    Hi
    For theme.json, try false instead of null.

  2. erikjoling commented on May 19, 2021

    @erikjoling
    Author

    Hi,

    Thank you for your suggestion.

    Unfortunately, that breaks the site-editor as well in my situation. "palette": false

  3. carolinan commented on May 19, 2021

    @carolinan
    Contributor

    "palette": [] ? (square brackets)

  4. added
    [Type] BugAn existing feature does not function as intended
    [Feature] Site EditorRelated to the overarching Site Editor (formerly "full site editing")
    on May 20, 2021
  5. erikjoling commented on May 20, 2021

    @erikjoling
    Author

    "palette": [] ? (square brackets)

    That doesn't break the site-editor, but at the same time it also doesn't disable the color controls (which is what I'm trying to test). The default colors are shown.

  6. arpadkdweb commented on Jun 4, 2021

    @arpadkdweb

    I experience the same issue. Also, if I use theme.json, I cannot disable editor color palettes anymore in functions.php as theme.json enjoys precedence.

  7. bobbingwide commented on Jul 26, 2021

    @bobbingwide
    Contributor

    It's not just the site editor that breaks when theme.json contains invalid values.

    I got the following Fatal error just visiting the site when I set settings.color.gradients to false.
    Setting it to an empty array resolved the problem.

    [26-Jul-2021 07:28:34 UTC] PHP Fatal error:  Uncaught TypeError: WP_Theme_JSON_Resolver_Gutenberg::translate_theme_json_chunk(): Argument #1 ($array_to_translate) must be of type array, bool given, called in C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\class-wp-theme-json-resolver-gutenberg.php on line 233 and defined in C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\class-wp-theme-json-resolver-gutenberg.php:170
    Stack trace:
    #0 C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\class-wp-theme-json-resolver-gutenberg.php(233): WP_Theme_JSON_Resolver_Gutenberg::translate_theme_json_chunk(false, 'name', 'Gradient name', 'written')
    #1 C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\class-wp-theme-json-resolver-gutenberg.php(280): WP_Theme_JSON_Resolver_Gutenberg::translate(Array, 'written')
    #2 C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\class-wp-theme-json-resolver-gutenberg.php(419): WP_Theme_JSON_Resolver_Gutenberg::get_theme_data(Array)
    #3 C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\global-styles.php(112): WP_Theme_JSON_Resolver_Gutenberg::get_merged_data(Array, 'user')
    #4 C:\apache\htdocs\wp55\wp-includes\class-wp-hook.php(294): gutenberg_experimental_global_styles_settings(Array)
    #5 C:\apache\htdocs\wp55\wp-includes\plugin.php(212): WP_Hook->apply_filters(Array, Array)
    #6 C:\apache\htdocs\wp55\wp-admin\edit-form-blocks.php(429): apply_filters('block_editor_se...', Array, Object(WP_Post))
    #7 C:\apache\htdocs\wp55\wp-admin\post.php(187): require('C:\\apache\\htdoc...')
    #8 {main}
      thrown in C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\class-wp-theme-json-resolver-gutenberg.php on line 170
    
  8. skorasaurus commented on Sep 20, 2021

    @skorasaurus
    Member

    I think there's some unclear expectations what values are expected for theme.json which could be minimized, in part by better documentation.

    Some objects' values in theme.json expect arrays; other objects' value expect binary true/false;

    Null is a valid value for JSON, additional reference source from json.org

  9. carolinan commented on Sep 21, 2021

    @carolinan
    Contributor

    There has been changes made since July 26:
    #34420
    #33280

  10. skorasaurus commented on Sep 21, 2021

    @skorasaurus
    Member

    @erikjoling to answer your question, how to remove all color panels including the default ones provided by Gutenberg, I believe the following works:

    		"color": {
          "custom": false,
          "customGradient": false,
    			"gradients": [],
    			"palette": []
    		},
    
  11. erikjoling commented on Sep 22, 2021

    @erikjoling
    Author

    You are right. The problem is solved since WP5.8. Closing this issue. Thanks for the useful information everyone!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Site EditorRelated to the overarching Site Editor (formerly "full site editing")[Type] BugAn existing feature does not function as intended[Type] Developer DocumentationDocumentation for developers

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions