Skip to content

Fix same-page anchor links being reset to top by Tito - #165

Merged
matrixise merged 1 commit into
mainfrom
fix-anchor-scroll-tito
Nov 18, 2026
Merged

matrixise merged 1 commit into
mainfrom
fix-anchor-scroll-tito

Conversation

@matrixise

Copy link
Copy Markdown
Contributor

Problem

On the homepage, clicking Tickets in the main menu (/#tickets) or the hero price link (#tickets) does not scroll to the tickets section in Firefox: the URL gets #tickets but the page stays at the top. Chromium usually wins the race thanks to smooth scrolling.

Root cause: the Tito widget script (js.tito.io) runs vue-router in the host page. It listens to popstate, which a native fragment navigation fires, then calls history.replaceState(…) and window.scrollTo({top: 0}) (traced to js.tito.io/packs/js/9381-….js). With Tito blocked, the same click scrolls correctly.

This was not introduced by #164: Tito was already loaded on the homepage before.

Fix

layouts/partials/nav.html: a click handler for same-page anchor links (plain left click, same origin/path, existing target, no target attribute):

  • scrolls with scrollIntoView({behavior: 'smooth'}),
  • updates the URL with history.pushState, which does not fire popstate, so Tito does not react,
  • closes the mobile menu when the link is inside it (it previously stayed open over the page).

Modifier-clicks (new tab, etc.), cross-page links (e.g. /#tickets from /schedule/) and external links keep native behaviour.

Also fixes a stale line in CLAUDE.md about where the Tito script is loaded.

Verification (Playwright, local build vs current production)

Case Firefox (PR) Chromium (PR) Firefox (prod)
Home, desktop menu "Tickets" ✅ ✅ ❌ stays at top
Home, hero price link ✅ ✅ ❌
Home, mobile menu "Tickets" ✅ menu closes ✅ menu closes ❌ menu stays open
/schedule/ → menu "Tickets" ✅ ✅ ✅

The Tito widget still renders in every case.

Known limitation: the browser Back button fires popstate, so Tito may still scroll to the top in that case.

🤖 Generated with Claude Code

The Tito widget script runs vue-router in the host page. It listens to
popstate, which a native fragment navigation fires, and then calls
window.scrollTo(0, 0). On the homepage, clicking "Tickets" in the menu
(/#tickets) or the hero price link (#tickets) left Firefox at the top of
the page.

- nav.html: intercept left-clicks on same-page anchor links, scroll to
  the target with scrollIntoView and update the URL with pushState,
  which does not fire popstate
- Close the mobile menu when such a link is clicked inside it
- CLAUDE.md: tickets.html no longer loads the Tito script (it is in
  head.html on the homepage only since #164); document the workaround
@netlify

netlify Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for pycon-ireland-2026 ready!

Name Link
🔨 Latest commit 323c0fd
🔍 Latest deploy log https://app.netlify.com/projects/pycon-ireland-2026/deploys/6afe042ba92b7d0e1c08423b
😎 Deploy Preview https://deploy-preview-165--pycon-ireland-2026.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@matrixise
matrixise merged commit 66aeeb1 into main Nov 18, 2026
6 checks passed
@matrixise
matrixise deleted the fix-anchor-scroll-tito branch November 18, 2026 20:04
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.

1 participant