Skip to content
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

Disable the default font sizes and JS TypeError #66858

Closed
3 of 6 tasks
stefanolissa opened this issue Nov 8, 2024 · 1 comment
Closed
3 of 6 tasks

Disable the default font sizes and JS TypeError #66858

stefanolissa opened this issue Nov 8, 2024 · 1 comment
Labels
[Feature] Typography Font and typography-related issues and PRs [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Bug An existing feature does not function as intended

Comments

@stefanolissa
Copy link
Contributor

Description

I'm trying to disable the defaultFontSizes (S, M, L, ...) using a filter over the theme.json (since it should be disabled only for a specific custom post type).

`add_filter('wp_theme_json_data_theme', function ($theme_json) {

    $new_data = array(
        'version' => 3,
        'settings' => array(
            'typography' => array(
                'fontSizes' => [],
                'defaultFontSizes' => false,
            ),
        ),
    );`

I followed the instructions here: https://wpdevelopment.courses/articles/block-editor-typography-settings/#disable-font-size-controls

Setting settings.typography.defaultFontSizes to false does nothing (WP 6.6.2, no plugins, 2024 theme).

Setting settings.typography.fontSizes to and empty array, leave the "sizes box" active without options (S, M, L, ... they disappear), but if you activate the custom size selector, which starts with an empty value, moving the slider does nothing and there is a JS error:

Uncaught TypeError: n?.startsWith is not a function at Dh (block-editor.min.js?ver=7ab6a9fdca1a0386ea66:21:312023) at onChange (block-editor.min.js?ver=7ab6a9fdca1a0386ea66:21:313162)

if you try to type a size directly the paragraph block disappear (I'm testing it on a paragraph block) and you get:

This block has encountered an error and cannot be previewed.

with the same error recorded in the JS console.

It's a bug or I'm doing something wrong? The defaultFontSizes should disable the default sizes selector?

Thanks, Stefano.

Step-by-step reproduction instructions

  1. filter the theme.json using wp_theme_json_data_theme and merge in the settings.typography.fontSizes = []
  2. create a post, add a paragraph and try to set the font size using the custom font size control

Screenshots, screen recording, code snippet

No response

Environment info

WP 6.6.2, no plugins, 2024 theme

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@stefanolissa stefanolissa added the [Type] Bug An existing feature does not function as intended label Nov 8, 2024
@t-hamano
Copy link
Contributor

t-hamano commented Nov 8, 2024

Thanks for the report. I believe this issue has also been reported in #62072, so I will close it.

@t-hamano t-hamano closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2024
@t-hamano t-hamano added [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Feature] Typography Font and typography-related issues and PRs labels Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Typography Font and typography-related issues and PRs [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants