Skip to content

LetterSpacingControl: Filter out percentage unit from available units#70479

Closed
Mayank-Tripathi32 wants to merge 2 commits intoWordPress:trunkfrom
Mayank-Tripathi32:try/fix-letter-spacing-percentage
Closed

LetterSpacingControl: Filter out percentage unit from available units#70479
Mayank-Tripathi32 wants to merge 2 commits intoWordPress:trunkfrom
Mayank-Tripathi32:try/fix-letter-spacing-percentage

Conversation

@Mayank-Tripathi32
Copy link
Contributor

What?

Closes #70478

Remove percentage (%) unit option from letter-spacing typography control dropdown.

Why?

Users were seeing "%" as an available unit option in the letter-spacing typography control, but percentage values are not valid CSS units for the letter-spacing property. When users selected percentage values, their letter-spacing settings would not work, causing confusion and frustration.

The CSS letter-spacing property accepts length values (px, em, rem, etc.) but not percentage values, making the percentage option misleading and non-functional.

How?

Modified the LetterSpacingControl component to filter out the % unit from the available units before passing them to the useCustomUnits hook. This follows the same pattern already used in the Spacer block control, which also filters out percentage units where they're not appropriate.

The change:

  • Filters the availableUnits array to exclude % when units are provided from settings
  • Maintains the existing fallback behavior when no settings are available
  • Adds a descriptive comment explaining why percentage units are disabled

Testing Instructions

  1. Open a post or page in the block editor
  2. Insert any block that supports typography settings (e.g., Paragraph, Heading, Button)
  3. Open the block settings panel
  4. Click on the Typography section
  5. Locate the "Letter spacing" control
  6. Click on the unit dropdown next to the letter spacing input
  7. Verify that "%" is no longer listed as an available unit option
  8. Confirm that other units (px, em, rem, vh, vw) are still available
  9. Test that letter spacing values work correctly with the remaining units

Screenshots or screencast

image

After: Letter spacing dropdown excludes "%" option, showing only functional units

@Mayank-Tripathi32 Mayank-Tripathi32 marked this pull request as ready for review June 19, 2025 18:16
@github-actions
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mayank-Tripathi32 <mayanktripathi32@git.wordpress.org>
Co-authored-by: iamtakashi <iamtakashi@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Feature] Typography Font and typography-related issues and PRs labels Jun 20, 2025
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

percentage values are not valid CSS units for the letter-spacing property

This may be a Chrome-specific bug, so we'd be cautious before moving forward with this PR.

See #70478 (comment)

@t-hamano t-hamano added the Browser Issues Issues or PRs that are related to browser specific problems label Jun 23, 2025
@Mayank-Tripathi32
Copy link
Contributor Author

Closing as the support for % is getting added slowly

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

Labels

Browser Issues Issues or PRs that are related to browser specific problems [Feature] Typography Font and typography-related issues and PRs [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove percentage unit from letter spacing

2 participants