AlignmentResearch / KataGoVisualizer

MIT License
3 stars 1 forks source link

sgf-viewer: Fix behavior of browser back button #100

Closed tomtseng closed 2 months ago

tomtseng commented 2 months ago

This PR fixes issues with the browser back button.

Bug 1: Navbar in Firefox.

Repro: In Firefox (but not in Chrome), go to goattack.far.ai, click on "Baseline Attacks" in the navbar, and click the browser back button. The URL changes, but unexpectedly, the page content does not go back to the home page.

Bug: I'm not sure why this only happens in Firefox, but here's what I think is happening in App.svelte to cause this issue:

Fix: Make the popstate handler directly update currentPath.

Other fixes I considered:

Maybe there's an cleaner fix, I'm not familiar with Svelte

Bug 2: Table of contents (ToC)

Repro: Go to goattack.far.ai/transfer and alternately click on the two ToC entries a bunch of times to navigate between URL fragments #leela and #elf. Now click the URL back button a few times. The expected browser history is [transfer#leela, transfer#elf, transfer#leela, transfer#elf, ...]. But instead the history is [transfer#leela, transfer, transfer#elf, transfer, transfer#leela, transfer, transfer#elf, ...]

Fix: Just get rid of the onClick handler in the ToC that modifies the history with window.history.pushState(). I'm not sure why that onClick handler existed.

Testing

Tested the PR on Firefox and Chrome

netlify[bot] commented 2 months ago

Deploy Preview for goattack ready!

Name Link
Latest commit 803434d92f384b1ee3fdb95d957e29d833bf109f
Latest deploy log https://app.netlify.com/sites/goattack/deploys/662af8a734c54600086a77e0
Deploy Preview https://deploy-preview-100--goattack.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

Lighthouse
1 paths audited
Performance: 90 (no change from production)
Accessibility: 95 (no change from production)
Best Practices: 100 (no change from production)
SEO: 85 (no change from production)
PWA: -
View the detailed breakdown and full score reports

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