Skip to content

Conversation

@jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Nov 3, 2025

Backports: WordPress/gutenberg#72923
Backports the required core changes to make fit text work correctly with the interactivity API.

Fit text did not work after navigating to a page using the Interactivity API router. When users navigated to a post via client-side navigation (e.g., in a Query block with pagination), fit text blocks would not recalculate their font sizes, appearing either too large or too small.

This occurred because the fit text initialization only ran on the window.load event, which doesn't fire during client-side navigation.

This PR refactors fit text front end to be an interactivity api first implementation, using an interactivity api init event instead of a window load event.

Ticket: https://core.trac.wordpress.org/ticket/64210

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

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.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jorgefilipecosta, mukesh27.

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

// Add Interactivity API directives for fit text to work with client-side navigation.
if ( ! empty( $block_content ) ) {
$processor = new WP_HTML_Tag_Processor( $block_content );
if ( $processor->next_tag() ) {
Copy link
Member

Choose a reason for hiding this comment

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

Q: Do we need to check if the block has the fitText attribute before setting it? Otherwise, this logic might apply the attribute to all block content elements, not just the ones that support fitText.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @mukeshpanchal27, we are checking if the block has fittext attribute on the condition above: if ( ! empty( $block['attrs']['fitText'] ) && ! is_admin() ) {.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/fit-text-interactivity-api branch from 21a28b8 to 9724dab Compare November 6, 2025 12:35
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61145
GitHub commit: 350d286

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Nov 6, 2025
@jorgefilipecosta jorgefilipecosta deleted the fix/fit-text-interactivity-api branch November 9, 2025 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants