Fix: Interactivity API: Native anchor links (#) trigger full page reload due to wpInteractivityId mismatch#76520
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
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
popstatelistener to only force reloads whenevent.stateis non-nulland has a mismatchedwpInteractivityId. - Add inline documentation explaining why
nullevent.stateshould 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>
There was a problem hiding this comment.
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
popstatelistener to only force a reload whenevent.stateis non-nulland the storedwpInteractivityIddoes not match the current session ID. - Add inline documentation clarifying why
nullstate 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.
DAreRodz
left a comment
There was a problem hiding this comment.
Looks good to me. I only added an e2e test that fails without the fix, and a changelog entry. Thanks, @hbhalodia!
|
I just cherry-picked this PR to the wp/7.0 branch to get it included in the next release: c8cd847 |
What?
Closes #76447
Why?
(#footer).How?
Testing Instructions
Step-by-step reproduction instructions
<a href="#footer">Go to Footer</a>.Testing Instructions for Keyboard
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