Skip to content

fix(admin): preserve panel scroll on rebuild (#615) - #616

Merged
CaYatur merged 1 commit into
mainfrom
fix/615-admin-sections-scroll
Sep 26, 2026
Merged

CaYatur merged 1 commit into
mainfrom
fix/615-admin-sections-scroll

Conversation

@CaYatur

@CaYatur CaYatur commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Fixes Admin UI: panel scroll jumps on mode / layer / type changes #615: Admin #sections scroll jumped on mode / layers / layer-type (and other render() rebuilds).
  • Keep capturing prevScroll, but re-apply after layout with double requestAnimationFrame, clamp to max scroll, and drop stale restores when render() runs again quickly.

Test plan

Linux box verification (2026-09-26, CaYatur / xvfb host)

  • Source: admin.js has sectionsScrollRestoreGen, double requestAnimationFrame, Math.min(prevScroll, max), isConnected guard
  • Unit: tests/admin-sections-scroll.test.js (source contract + behavioral) — node --test → 5 pass (follow-up test(admin): cover #sections scroll restore (#615/#616) #618)
  • GUI: Open Admin, scroll mid-panel on Scene (not run — no interactive Admin click-through on this Linux box)
  • GUI: Change visualizer/background mode — scroll stays
  • GUI: Expand/enable layers and change a layer type — scroll stays
  • GUI: Rapid toggles do not snap to top
  • GUI: MilkDrop list scroll behavior unchanged

Sync scrollTop right after innerHTML was clamped before layout settled
when mode/layer/type changes rebuilt the panel. Restore after layout
(double rAF + clamp), and ignore stale restores from rapid re-renders.
@CaYatur

CaYatur commented Sep 26, 2026

Copy link
Copy Markdown
Owner Author

Linux box verification — 2026-09-26 (Europe/Istanbul)

Verified on this host (CaYatur / gh auth):

  • Source contract in src/admin/admin.js: sectionsScrollRestoreGen, double requestAnimationFrame, Math.min(prevScroll, max), isConnected guard — present on main.
  • New unit test tests/admin-sections-scroll.test.js: node --test → 5 pass (follow-up PR test(admin): cover #sections scroll restore (#615/#616) #618).

Not done: interactive Admin GUI click-through (Scene scroll / mode / layers / rapid toggles / MilkDrop list). Those GUI boxes stay unchecked — unit + source cover the algorithm on Linux without Electron UI driving.

CaYatur added a commit that referenced this pull request Sep 26, 2026
* test(admin): cover #sections scroll restore (#615/#616)

Source contract + behavioral simulation (fake element, controllable rAF)
for gen++, double rAF, clamp, and isConnected skip.

* docs: bump unit test count to 2202 for admin scroll tests

---------

Co-authored-by: CaYaTur <contact@cayadev.com>
CaYatur added a commit that referenced this pull request Sep 26, 2026
Adds tests/admin-sections-scroll.test.js for the Admin #sections scroll
restore pattern (source contract + behavioral simulation) and bumps the
documented unit test count to 2202.
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.

Admin UI: panel scroll jumps on mode / layer / type changes

1 participant