Skip to content

Keep fullscreen across pages in the same tab (#370) - #371

Merged
margani merged 1 commit into
mainfrom
issue/370-fullscreen-persist
Oct 20, 2026
Merged

margani merged 1 commit into
mainfrom
issue/370-fullscreen-persist

Conversation

@margani

@margani margani commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Closes #370

Reported by @xmha97: turning on fullscreen and then opening a game (or going back to the menu) dropped back to the browser window.

Why

Every game is its own page, and a browser ends fullscreen on every page load. It only enters it again from a user activation, so it cannot simply be switched back on at load.

What changed

  • www/lib/chogan.js: after Chogan.fullscreen, a small block keeps the choice in sessionStorage (chogan.fullscreen, this tab only, nothing saved across sessions). On the next page, the first pointerup/keydown/click (capture phase, Escape excluded, only with navigator.userActivation.isActive) re-enters fullscreen and the listeners are removed. The exit that comes from leaving the page (after pagehide) is ignored; exiting on the page (button, Esc, back gesture) clears it. A tap on the fullscreen button itself is left to the button (data-fs), otherwise restoring first would make the button exit again.
  • tools/test.js: testFullscreenCarry() runs the real core section against a fake browser across three pages. MIN_CHECKS 4185 → 4203 (4191 on main + 13 new checks, minus one).

Proof

Test on main's code with the new test.js: ✗ 5 errors of 4204 checks (remembered, ignore leave exit, next page waits, first tap re-enters, data-fs). On the branch: all 4204 checks green, exit 0. tools/browser-check.sh: 36 of 36 pages, exit 0.

Headless Chrome (Playwright), dots → fullscreen → navigate to sudoku → tap:

main branch
game after first tap false true
after exiting on a page, next page tap false false
pending page, first tap on the button – true
next page, first key – true

Screenshots at 1280 and 390, fa/en, light/dark: layout unchanged, the bar button shows "Exit fullscreen" after the restore, and the restoring tap still reaches the game (a cell gets selected).

Not tested

Real Android Chrome and iOS Safari (iPhone Safari has no Fullscreen API for pages, so the button is not shown there anyway). The Android app is unaffected (available() is false under Capacitor).

🤖 Generated with Claude Code

Each game is its own document, so every navigation between the menu and a
game left fullscreen, and the player had to press the button again on each
page. The choice is now kept in sessionStorage for the tab and the first tap
or key on the next page re-enters fullscreen (a browser refuses it without a
user activation). The exit caused by leaving the page is ignored; turning it
off on the page forgets it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@margani

margani commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Diff review

  • chogan.js: the new block returns early when available() is false, so the Android app and an installed fullscreen PWA register nothing. sessionStorage instead of the app settings on purpose: a new tab or a new day should not jump into fullscreen on the first tap.
  • pagehide sets leaving before the document is unloaded, so the fullscreen exit caused by navigation does not clear the choice; pageshow resets it for a page restored from the back/forward cache. Proven in headless Chrome (the next page did restore).
  • The restore listeners are capture-phase on window, so a game that stops propagation on its canvas cannot hide the tap; they do not call preventDefault, so the tap still acts in the game (seen in the screenshot: a cell got selected).
  • navigator.userActivation.isActive avoids a refused request on a click synthesised without activation; when the API is missing the request is just tried and a refusal is swallowed.
  • Risk: the first tap on a restored page also resizes the page mid-gesture (that is what entering fullscreen does). For a drag-based game the first drag may feel the jump once. Acceptable for what was asked.
  • Not tested on a real phone browser.

@margani
margani merged commit 986c7e3 into main Oct 20, 2026
3 checks passed
@margani
margani deleted the issue/370-fullscreen-persist branch October 20, 2026 02:44
@margani margani mentioned this pull request Oct 20, 2026
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.

Full-Screen Mode Doesn't Persist

1 participant