Skip to content

Interactivity API: Load the script module registry from its current path - #86454

Open
westonruter wants to merge 1 commit into
trunkfrom
fix/modules-registry-path
Open

westonruter wants to merge 1 commit into
trunkfrom
fix/modules-registry-path

Conversation

@westonruter

Copy link
Copy Markdown
Member

What?

Follow up to #74490. Found in #86104.

Fixes the path that gutenberg_define_interactivity_modules_support() loads the script module registry from, so that it marks the block library's script modules as able to load on client-side navigation again.

Why?

The function reads the registry from build/modules/index.php, but #74490 renamed that file to build/modules/registry.php and did not update this caller. Since then, its file_exists() check has always failed, and it has returned without marking anything.

This has gone unnoticed because Core marks the block library modules it registers in wp_default_script_modules(), and that mark is kept when Gutenberg registers the modules again. All 10 of Gutenberg's current block library modules are also in Core, so none are affected today. A block library module that only Gutenberg has, though, would not be marked, so it would not be loaded on client-side navigation.

How?

  • Load the registry from build/modules/registry.php, where wp-build writes it, as the generated build/modules.php already does.
  • Remove the remove_action( 'wp_default_scripts', 'wp_define_interactivity_modules_support' ) call. Core has never defined that function, so the call has never done anything.

Testing Instructions

  1. Run npm run build, and confirm that build/modules/registry.php exists and build/modules/index.php does not.
  2. Save the following as check-registry-path.php in a directory that WP-CLI can read, and run it with wp eval-file check-registry-path.php (or npm run wp-env run cli wp eval-file …). It clears the marks that Core added, then runs only Gutenberg's function:
    <?php
    wp_scripts(); // Fires wp_default_scripts.
    $prop = new ReflectionProperty( WP_Interactivity_API::class, 'script_modules_that_can_load_on_client_navigation' );
    $prop->setValue( wp_interactivity(), array() );
    gutenberg_define_interactivity_modules_support();
    printf( "Marked: %d\n", count( $prop->getValue( wp_interactivity() ) ) );
  3. On trunk, it prints Marked: 0. With this PR, it prints Marked: 10, one for each @wordpress/block-library/*/view module.
  4. Optional smoke test: on the front end, check that client-side navigation still works for a Query Loop block with "Reload full page" disabled.

Testing Instructions for Keyboard

Not applicable. There are no UI changes.

Screenshots or screencast

Not applicable.

Use of AI Tools

This PR was written with Claude Code using Claude Opus 5.5 (medium effort), which found the stale path while typing the registry in #86104, traced it to #74490, verified the fix against a local site with WP-CLI, and drafted the change and this description. It was reviewed by a maintainer.

`gutenberg_define_interactivity_modules_support()` marks the block library's script modules as able to load on client-side navigation. It read the registry from `build/modules/index.php`, but acf01a2 (#74490) renamed that file to `build/modules/registry.php` and did not update this caller. Since then, the `file_exists()` check has always failed, and the function has returned without marking anything.

This went unnoticed because Core marks the block library modules it registers in `wp_default_script_modules()`, and that mark is kept when Gutenberg registers the modules again. A block library module that only Gutenberg has, though, would not be marked, so it would not be loaded on client-side navigation.

Also remove the `remove_action()` call for `wp_define_interactivity_modules_support()`, which Core has never defined.

Co-Authored-By: Claude Opus 5.5 (medium effort) <noreply@anthropic.com>
Claude-Code-Session-Id: 32212707-a7f1-4bca-bef2-7f3b4982950b
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

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: westonruter <westonruter@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 4f92695 trunk % Change
timeToFirstByte 53.9 ms +4.27% -2.41% 54.7 ms +6.22% -3.84% -1.46%
largestContentfulPaint 92 ms +4.35% -4.35% 92 ms +4.35% -8.7% 0%
lcpMinusTtfb 37.1 ms +9.7% -9.43% 33.5 ms +17.61% -4.63% 10.75%
wpBeforeTemplate 28.01 ms +12.82% -1.89% 28.41 ms +8.17% -3.2% -1.41%
wpTemplate 21.56 ms +3.29% -3.62% 21.92 ms +5.2% -4.79% -1.64%
wpTotal 50.08 ms +4.85% -2.26% 51.06 ms +6.35% -4.52% -1.92%
wpMemoryUsage 7.72 MB +0% -0% 7.69 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 4f92695 trunk % Change
timeToFirstByte 44.95 ms +7.68% -2.89% 44.85 ms +5.91% -2.56% 0.22%
largestContentfulPaint 96 ms +4.17% -0% 96 ms +4.17% -0% 0%
lcpMinusTtfb 51.75 ms +1.16% -1.35% 51.7 ms +1.26% -1.06% 0.1%
wpBeforeTemplate 25.54 ms +13.08% -1.72% 25.41 ms +1.57% -1.02% 0.51%
wpTemplate 16.05 ms +3.05% -3.55% 16.27 ms +3.5% -3.87% -1.35%
wpTotal 42.01 ms +7.5% -3.21% 41.77 ms +6.32% -2.11% 0.57%
wpMemoryUsage 6.41 MB +0% -0% 6.38 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 4f92695 trunk % Change
mediaProcessingJpeg 401.52 ms +1.12% -0.53% 394.28 ms +0.74% -0.18% 1.84%
mediaProcessingAvif 6112.01 ms +0.18% -0.15% 6123.66 ms +0.23% -0.34% -0.19%
mediaProcessingJpegToAvif 4199.01 ms +0.35% -0.2% 4204.91 ms +0.16% -0.03% -0.14%

media-upload

Metric 4f92695 trunk % Change
jpegUploadProcessing 1464.3 ms +33.87% -1.18% 1464.62 ms +0.67% -1.1% -0.02%
pngUploadProcessing 171.11 ms +37.37% -4.67% 173.69 ms +33.9% -6.49% -1.49%
largeJpegUploadProcessing 1451.54 ms +0.96% -0.62% 1457.3 ms +1.7% -0.38% -0.4%
multipleImageUploadProcessing 2036.51 ms +0.71% -2.01% 2017.89 ms +3.84% -5.72% 0.92%

post-editor

Metric 4f92695 trunk % Change
serverResponse 253.66 ms +8.65% -5.97% 263.67 ms +10.08% -3.3% -3.8%
firstPaint 286.25 ms +15.06% -15.9% 323.2 ms +9.6% -21.26% -11.43%
domContentLoaded 584.81 ms +2.92% -1.24% 617.66 ms +0.35% -1.42% -5.32%
loaded 585.72 ms +2.9% -1.26% 618.6 ms +0.34% -1.43% -5.32%
firstContentfulPaint 347.04 ms +4.2% -0.82% 361.08 ms +2.51% -1.9% -3.89%
firstBlock 1461.25 ms +2.99% -0.91% 1547.63 ms +1.61% -0.43% -5.58%
type 14.59 ms +3.22% -7.47% 14.28 ms +2.87% -4.48% 2.17%
typeWithoutInspector 13.51 ms +9.84% -9.47% 13.38 ms +8.59% -10.24% 0.97%
typeWithTopToolbar 16.03 ms +9.86% -5.8% 17.12 ms +4.38% -3.56% -6.37%
typeContainer 6.17 ms +5.19% -5.67% 6.22 ms +3.54% -5.63% -0.8%
focus 77.7 ms +5.08% -6.63% 75.51 ms +6.57% -5.48% 2.9%
firstFocus 169.28 ms +0% -0% 169.26 ms +0% -0% 0.01%
selectAll 263.1 ms +1.65% -7.67% 246.51 ms +0.85% -1.33% 6.73%
undo 21.24 ms +6.97% -4.8% 21.83 ms +3.07% -4.31% -2.7%
listViewOpen 48.82 ms +4.79% -5.31% 49.53 ms +11.87% -10.72% -1.43%
inserterOpen 29.86 ms +1.07% -4.25% 28.22 ms +4.22% -10.52% 5.81%
inserterHover 9.37 ms +10.78% -11.63% 8.48 ms +6.96% -9.43% 10.5%
inserterSearch 7.48 ms +2.41% -4.81% 6.6 ms +6.67% -3.79% 13.33%
loadPatterns 445.2 ms +3.38% -1.76% 493.78 ms +5.4% -4.49% -9.84%
wpTotal 246.68 ms +8.96% -6.01% 256.56 ms +9.85% -3.39% -3.85%
wpMemoryUsage 14.78 MB +0% -0% 14.74 MB +0% -0% 0.24%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 4f92695 trunk % Change
serverResponse 462.8 ms +2.39% -4.88% 468.54 ms +0.4% -8.76% -1.23%
firstPaint 377.73 ms +14.73% -11.7% 359.25 ms +3.43% -12.55% 5.14%
domContentLoaded 874.31 ms +5.74% -1.76% 862.03 ms +0.63% -0.98% 1.42%
loaded 875.35 ms +5.72% -1.76% 863.14 ms +0.6% -1% 1.41%
firstContentfulPaint 510.66 ms +8.39% -2.49% 498.29 ms +2.39% -2.7% 2.48%
firstBlock 2575.74 ms +5.24% -0.95% 2555.65 ms +0.77% -0.77% 0.79%
type 17.93 ms +3.74% -8.64% 17.04 ms +7.69% -10.04% 5.22%
navigate 116.99 ms +2.56% -6.28% 116.6 ms +3.57% -7.25% 0.33%
loadPatterns 1348.02 ms +7.35% -2.82% 1316.68 ms +11.06% -13.32% 2.38%
loadPages 976.31 ms +3.65% -4.15% 992.36 ms +1.08% -1.52% -1.62%
wpTotal 453.42 ms +2.43% -5.02% 459.07 ms +0.41% -8.93% -1.23%
wpMemoryUsage 12.79 MB +0% -0% 12.76 MB +0% -0% 0.27%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

5fa74d7 Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

Page List converts to Navigation Links with entity bindings in /test/e2e/specs/editor/blocks/navigation.spec.js, passed after 1 failed attempt.
Error: expect(locator).toContainText(expected) failed

Locator: getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ })
Expected substring: "test-page-1"
Received string:    "Link to:Cat/catPagePublished"
Timeout: 5000ms

Call log:
  - Expect "toContainText" getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ }) with timeout 5000ms
  - waiting for getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ })
    14 × locator resolved to <button type="button" aria-expanded="false" aria-haspopup="dialog" class="components-button link-preview-button is-next-40px-default-size is-secondary">…</button>
       - unexpected value "Link to:Cat/catPagePublished"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation.spec.js:1949:31
does not select blocks in the canvas preview when editing from the sidebar (Site Editor v2) in /test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator: getByRole('combobox', { name: 'Search or type URL' })
Expected: focused
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeFocused" getByRole('combobox', { name: 'Search or type URL' }) with timeout 5000ms
  - waiting for getByRole('combobox', { name: 'Search or type URL' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:416:47)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:21
should undo without broken temporary state in /test/e2e/specs/editor/blocks/image.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:image -->
- <figure class="wp-block-image"><img alt=""/></figure>
+ <!-- wp:image {"id":26,"sizeSlug":"full","linkDestination":"none"} -->
+ <figure class="wp-block-image size-full"><img src="http://localhost:8889/wp-content/uploads/2026/11/eb2890f2-9b50-43fe-8c09-73c78308510e.png" alt="" class="wp-image-26"/></figure>
  <!-- /wp:image -->
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/image.spec.js:432:49

5fa74d7 Run

@westonruter westonruter added [Type] Bug An existing feature does not function as intended [Feature] Interactivity API API to add frontend interactivity to blocks. [Feature] Script Modules API Related to the Script Modules API that adds support for native ES modules and import maps No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core labels Nov 6, 2026
@westonruter
westonruter marked this pull request as ready for review November 6, 2026 18:08

This branch has not been deployed

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

Labels

[Feature] Interactivity API API to add frontend interactivity to blocks. [Feature] Script Modules API Related to the Script Modules API that adds support for native ES modules and import maps No Core Sync Required Indicates that any changes do not need to be synced to WordPress Core [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant