Skip to content

fix(webfont-loader): point WebfontLoader to the fixed loader - #28

Open
faisalahammad wants to merge 2 commits into
stellarwp:mainfrom
faisalahammad:fix/1455-editor-google-fonts
Open

faisalahammad wants to merge 2 commits into
stellarwp:mainfrom
faisalahammad:fix/1455-editor-google-fonts

Conversation

@faisalahammad

@faisalahammad faisalahammad commented Oct 13, 2026 •

Copy link
Copy Markdown

Summary

Google Fonts do not load in the block editor since Kadence Blocks 3.7.3. Version 1.1.10 fixed KadenceWebfontLoader, but the WebfontLoader export still points to the old simple-web-font-loader, which builds URLs that Google rejects. This points WebfontLoader to the fixed loader too.

Fixes stellarwp/kadence-blocks#1455 (for the blocks that use WebfontLoader)

Changes

src/index.js

Before:

export { default as WebfontLoader } from './simple-web-font-loader';

After:

export { default as WebfontLoader } from './simple-webfont-loader';

Why: Countdown, Form, Testimonials, Tabs, Info Box, Progress Bar, Count Up and Advanced Gallery use WebfontLoader. With this they get the fixed loader, with no change on the blocks side. The fixed loader already reads the legacy config prop these blocks pass.

src/simple-web-font-loader/index.js (removed)

const url = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(
	family.replace(/ /g, '+')
)}&display=swap`;

Why: Blocks pass Open Sans:700italic. This becomes family=Open%2BSans%3A700italic, which returns 400. It also skipped the load on first mount. Nothing uses this folder after the export change.

src/simple-webfont-loader/__tests__/index.test.js

One new test: a multi-word family with a variant from a legacy config (Open Sans:700italic) loads family=Open+Sans:ital,wght@1,700. This is the shape WebfontLoader callers send.

Testing

Test 1: Unit tests

  1. npm install && npm test
    Result: the 2 webfont loader suites pass, including the new test.

Test 2: Block editor (Kadence Blocks with this branch)

  1. Add a Countdown, set the number font to Playfair Display 700 italic.
  2. Reload the editor without clicking any block.
    Result: the font renders in the editor. The request to fonts.googleapis.com/css2 returns 200.

Note: anything importing @kadence/components/src/simple-web-font-loader directly will break, since that folder is removed. I did not find such imports in Kadence Blocks.

Both editor font loaders were broken since 3.7.3 of Kadence Blocks.

WebfontLoader built a css2 URL that Google rejects with a 400 for any
multi-word family or any family with a weight, and it skipped the load
on first mount. KadenceWebfontLoader only read the `config` prop, while
the blocks pass `typography`, so it loaded nothing.

Point both exports at the fixed loader from simple-webfont-loader. It
accepts `typography` or a legacy `config`, builds valid css2 URLs
(family=Open+Sans:ital,wght@1,700), loads on mount, and removes fonts
the block no longer uses. Remove the broken simple-web-font-loader.

Add unit tests for the loader and the URL builder, plus the jest setup
to run them.

Fixes stellarwp/kadence-blocks#1455
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 71eccd82-8a79-4a4a-a8cd-19c84b820c90
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

main already has the KadenceWebfontLoader fix in 1.1.10, so for the shared
files (font-request.js, tests, jest config, package files) I took the main
version.

What is left in this PR: point the WebfontLoader export to the fixed loader
and remove the old simple-web-font-loader, which still builds bad Google
Fonts URLs. Also keep the test for a multi-word family from a legacy config.
@faisalahammad faisalahammad changed the title fix(webfont-loader): load Google Fonts in the editor again fix(webfont-loader): point WebfontLoader to the fixed loader Oct 13, 2026
faisalahammad added a commit to faisalahammad/kadence-blocks that referenced this pull request Oct 14, 2026
master now pins @kadence/components 1.1.10, which has the
KadenceWebfontLoader fix. I keep the fork ref here because the
WebfontLoader fix (stellarwp/kadence-components#28) is not in a tag yet.
Took @kadence/helpers 1.1.1 from master and regenerated bun.lock.
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.

Kadence block fonts not loading correctly at editor

1 participant