Skip to content

Fix: Interactivity API: Native anchor links (#) trigger full page reload due to wpInteractivityId mismatch#76520

Merged
DAreRodz merged 4 commits intoWordPress:trunkfrom
hbhalodia:fix/issue-76447
Mar 16, 2026
Merged

Fix: Interactivity API: Native anchor links (#) trigger full page reload due to wpInteractivityId mismatch#76520
DAreRodz merged 4 commits intoWordPress:trunkfrom
hbhalodia:fix/issue-76447

Conversation

@hbhalodia
Copy link
Copy Markdown
Contributor

@hbhalodia hbhalodia commented Mar 16, 2026

What?

Closes #76447

Why?

How?

Testing Instructions

Step-by-step reproduction instructions

  1. Use a WordPress site with Gutenberg 22.7.0 enabled
  2. Create a page with long content and a standard HTML anchor link: <a href="#footer">Go to Footer</a>.
  3. Ensure the page also has some block that requires interactivity (Ex: a core/navigation block)
  4. Click the Go to Footer link.
  5. Observed behavior: The page reloads entirely instead of simply scrolling to the ID.
  6. Expected behavior: The browser should navigate to the fragment identifier without a page refresh.

Testing Instructions for Keyboard

  • None

Screenshots or screencast

Before

Screen.Recording.2026-03-16.at.11.13.54.AM.mov

After

Screen.Recording.2026-03-16.at.11.13.16.AM.mov

Use of AI Tools

  • None

@hbhalodia hbhalodia requested review from Copilot and removed request for DAreRodz and luisherranz March 16, 2026 05:50
@hbhalodia hbhalodia self-assigned this Mar 16, 2026
@github-actions github-actions bot added the [Package] Interactivity /packages/interactivity label Mar 16, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 16, 2026

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: hbhalodia <hbhalodia@git.wordpress.org>
Co-authored-by: DAreRodz <darerodz@git.wordpress.org>
Co-authored-by: TobiasBg <tobiasbg@git.wordpress.org>
Co-authored-by: joshuadwire <jdwire@git.wordpress.org>

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

@hbhalodia hbhalodia added the [Type] Bug An existing feature does not function as intended label Mar 16, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an Interactivity API regression where clicking native fragment/anchor links (e.g. #footer) could trigger a full page reload due to the popstate handler treating null history state as a session ID mismatch.

Changes:

  • Update the popstate listener to only force reloads when event.state is non-null and has a mismatched wpInteractivityId.
  • Add inline documentation explaining why null event.state should not trigger a reload for fragment navigations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an Interactivity API regression where native fragment/anchor navigations (e.g. href="#footer") could trigger a full page reload due to the popstate handler treating null history state as a session mismatch.

Changes:

  • Update the popstate listener to only force a reload when event.state is non-null and the stored wpInteractivityId does not match the current session ID.
  • Add inline documentation clarifying why null state should not trigger reloads (hash/fragment same-document navigations).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown
Contributor

@DAreRodz DAreRodz left a comment

Choose a reason for hiding this comment

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

Looks good to me. I only added an e2e test that fails without the fix, and a changelog entry. Thanks, @hbhalodia!

@DAreRodz DAreRodz enabled auto-merge (squash) March 16, 2026 19:29
@DAreRodz DAreRodz disabled auto-merge March 16, 2026 19:29
@DAreRodz DAreRodz enabled auto-merge (squash) March 16, 2026 19:30
@DAreRodz DAreRodz added [Feature] Interactivity API API to add frontend interactivity to blocks. Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Mar 16, 2026
@DAreRodz DAreRodz merged commit 74ed033 into WordPress:trunk Mar 16, 2026
51 of 52 checks passed
@github-actions github-actions bot removed the Backport to WP 7.0 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Mar 16, 2026
@github-actions github-actions bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Mar 16, 2026
@github-actions
Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.0 branch to get it included in the next release: c8cd847

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

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Feature] Interactivity API API to add frontend interactivity to blocks. [Package] Interactivity /packages/interactivity [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interactivity API: Native anchor links (#) trigger full page reload due to wpInteractivityId mismatch

3 participants