WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.36k stars 4.13k forks source link

FontSizePicker in the TypographyPanel uses font size value instead of the slug #64223

Open SH4LIN opened 1 month ago

SH4LIN commented 1 month ago

Description

When you have two font sizes with the same value but different slugs, selecting the second item will automatically select the first matching font value.

This is problematic when you use fluid typography for example there is one font size with a value of 1rem it's max value is 1rem and min value is 0.875rem and there is another font size with a value of 1rem it's max value is 1rem and min value is 0.5rem in that case the current implementation doesn't work.

Step-by-step reproduction instructions

  1. In theme.json add the following font size preset
    {
    "fluid": {
        "min": "0.5rem",
        "max": "1rem"
    },
    "size": "1rem",
    "slug": "x-small"
    },
    {
    "fluid": {
        "min": "0.875rem",
        "max": "1rem"
    },
    "size": "1rem",
    "slug": "small"
    },
  2. Try selecting small font size in editor it will select x-small always.

Screenshots, screen recording, code snippet

No response

Environment info

WordPress version: Latest

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

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

hanneslsm commented 1 month ago

Thanks @SH4LIN for the report! There is a already existing issue for this: https://github.com/WordPress/gutenberg/issues/42683

@annezazu Could you please add the other issue to the polish board? I have created the same bug report (which was on the Polish board) a year ago and it'd be wonderful if we could get some traction on this kind of issues.