Skip to content

Auto-scroll orbital list to keep the selected orbital visible#20

Merged
dnkats merged 1 commit into
mainfrom
fix/orbital-list-autoscroll
May 31, 2026
Merged

Auto-scroll orbital list to keep the selected orbital visible#20
dnkats merged 1 commit into
mainfrom
fix/orbital-list-autoscroll

Conversation

@dnkats

@dnkats dnkats commented May 31, 2026

Copy link
Copy Markdown
Member

Problem

In the orbital list, pressing ↑/↓ (or using the HOMO/LUMO buttons) moved the selection, but the list did not scroll to follow it. The highlighted orbital could move off-screen, so you couldn't see which orbital was selected.

Fix

After updateOrbitalList() rebuilds the list and tags the current orbital with .selected, scroll the #orbitalList container so the selected entry stays in view. Uses getBoundingClientRect deltas to adjust only list.scrollTop — it never scrolls the page or the surrounding panel, and only scrolls when the entry is actually outside the visible area (so it doesn't jump around unnecessarily).

Testing

  • Inline <script> blocks pass a JS syntax check.
  • Manual check in the desktop app (npm start): load a structure with orbital data, open the orbital panel, and hold ↑/↓ — the list should now track the selection in both directions.

🤖 Generated with Claude Code

When navigating orbitals with the arrow keys (or HOMO/LUMO buttons), the
selection moved but the list did not scroll, so the highlighted orbital
could end up off-screen. After rebuilding the list, scroll the list
container (only the list, not the page) so the selected entry stays in
view.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 31, 2026 15:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the orbital navigation UX by automatically scrolling the orbital list so the currently selected orbital remains visible when the selection changes via ↑/↓ keys or the HOMO/LUMO controls.

Changes:

  • Track the newly-created selected orbital DOM node while rebuilding the list.
  • After rebuilding, adjust #orbitalList.scrollTop only when the selected item is outside the list’s visible viewport (using getBoundingClientRect deltas).

@dnkats dnkats merged commit dbab183 into main May 31, 2026
1 check passed
@dnkats dnkats deleted the fix/orbital-list-autoscroll branch May 31, 2026 15:15
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.

2 participants