Stop the Today tab jumping the viewport too

The last change stopped showTab scrolling, which fixed four of the five tabs.
Today kept jumping, because getting there is not an ordinary tab switch: it is
a history step. Tapping the tab spends the armed entry with history.back(), the
back button pops the same one, and either way the browser restores the scroll
position it saved against the entry it lands on — wherever you happened to be
when you left Today. showTab scrolling nothing made no difference; the scroll
was the browser's, not ours.

So scroll restoration is turned off for the document. Tabs are not pages and
carry no scroll of their own to restore, so the automatic behaviour has nothing
useful to offer here. It also governs reloads, which now open at the top, which
is the right place for this app to start anyway.

The harness gained an assertion for it, and it was checked by removing the line
and watching it fail — a browser silently undoing what the code just did is
exactly the sort of thing that slips past a test that was never seen to break.
This commit is contained in:
Alexander Heldt
2026-09-07 20:18:31 +00:00
parent 39343ff2a4
commit 7c0ccca1b2
2 changed files with 11 additions and 0 deletions
+10
View File
@@ -4721,6 +4721,16 @@
// from tapping the tab.
let backArmed = false;
// Returning to Today is a history navigation — by the back button, or by
// tapping the tab, which spends the same entry — and a browser restores the
// scroll position it saved against the entry it lands on. That position is
// wherever you happened to be when you left Today, so the viewport jumped on
// arrival even though showTab itself scrolls nothing. Tabs are not pages and
// carry no scroll of their own to restore, so the automatic behaviour has
// nothing useful to offer here and is turned off. (It also governs reloads,
// which now open at the top — the right place to start anyway.)
if ("scrollRestoration" in history) history.scrollRestoration = "manual";
function armBack() {
if (backArmed) return;
history.pushState({ puppyTab: true }, "");
+1
View File
@@ -1,4 +1,5 @@
[
{ "date": "2026-09-07", "text": "Going back to the Today tab no longer jumps the viewport either — by tapping it or with the back button. The other tabs stopped jumping in the last change, but returning to Today is a history step, and the browser was restoring the scroll position from when you last left it" },
{ "date": "2026-09-07", "text": "The tab row now matches the frozen row above it that holds the date. It was a different shade, and the two sat as separate bars with the date row's rounded corners cutting between them; they share the same card colour now, and once you have scrolled the log buttons away they join into a single rounded block instead of two stacked ones" },
{ "date": "2026-09-07", "text": "Switching tabs no longer jumps the page back to the top. The tab row is frozen to the top of the screen, so you change tabs from wherever you have scrolled to, and being thrown back past the log buttons you had just scrolled off was more disruptive than landing part-way down the new tab" },
{ "date": "2026-09-07", "text": "The page is split into five tabs — Today, Sleep, Walks, Habits and Growth — instead of one long column of fourteen panels. Today has the overview, sleep & wake and the day's history; Sleep and Walks each have their day-by-day chart, their when-it-happens grid and their trend; Habits has the pee, poo and meal timing and counts; Growth has weight, training and notes. Getting to the weight curve no longer means scrolling past everything else. The day bar and the log buttons sit above the tabs and stay there whichever one you're on, so logging is still one tap from anywhere. Folding a panel by tapping its heading works exactly as before, inside its tab, and the app reopens on the tab you left it on. The back button (or the back gesture) returns you to Today from wherever you are, and pressing it again leaves the app — always two presses to get out, however much you'd been flicking between tabs beforehand" },