Repository navigation
fix(traffic): keep the keyboard-selected row in view - #111
Merged
Merged
Conversation
Arrow keys move the highlight in the traffic table, but the handler calls preventDefault() to stop the page from scrolling and nothing scrolls instead, so pressing Down past the bottom of the visible area took the highlight off-screen, and Up past the top did the same. - After each Up/Down the selected row is scrolled into view with block: "nearest": only as far as needed. It also runs when the cursor is already at the first or last row, so a key press brings back a row that was scrolled away with the wheel. - The row is found by request id (data-row), not by index, so the grouped view works too. A row inside a collapsed session is not in the table; then nothing scrolls. - Request rows get scroll-margin-top equal to the pinned header (36px), so a row moving up stops below the header, not under it. - Request rows get a 100vw inline scroll margin, so "nearest" never scrolls sideways when the table is wider than the window. Without it Chromium shifts the table by its 20px padding at either end and WebKit jumps from the far right back to the far left; a margin of exactly 20px is not enough in WebKit, which rounds the scroll width up and leaves the row a fraction of a pixel short at the far right. - Up/Down are left alone while the session drawer is open, as they already were for the request drawer. Otherwise the list behind the drawer would now scroll with the cursor. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Arrow keys move the highlight in the traffic table, but the keyboard handler in
App.tsxcallspreventDefault()to stop the page from scrolling, and nothing scrolls instead. With up to 200 rows, pressing ↓ past the bottom of the visible area takes the highlight off-screen, and ↑ back past the top does the same.What changes
After each ↑/↓ the selected row is scrolled into view with
scrollIntoView({ block: "nearest" }): only as far as needed, and not at all when it is already visible. It also runs when the cursor is already at the first or last row, so a key press brings back a row that was scrolled away with the wheel.The row is found by request id (
data-row, as the other tables do), not by index, so the grouped view works: there the on-screen order is not the order ofrows. A row inside a collapsed session is not in the table; then nothing scrolls.Request rows get
scroll-margin-topequal to the height of the pinned header (36px: the 24px sort buttons plus the status cell'spy-1.5). Without it, a row moving up stops underneath the header from fix(traffic): keep the table header pinned while the list scrolls #108.Request rows also get a
100vwinline scroll margin. When the table is wider than the window (820px with the sidebar expanded), a row always sticks out of the visible area sideways, andnearestscrolls horizontally for it:scrollLeft0 → 20, and max → max − 20);scrollLeft225 → 20).A margin of exactly the 20px padding fixes Chromium and the left end in WebKit, but at the far right WebKit still jumps (225 → 0): it rounds the scroll width up (848.84 → 849), so the row falls 0.16px short of the right edge, counts as partly visible and is aligned to the left. With a margin wider than any viewport, neither engine scrolls sideways for a row (in WebKit, starting at 0, 100 and 225 all stay put), and the margin no longer depends on the padding of the block around the table.
↑/↓ are left alone while the session drawer is open, as they already were for the request drawer (the comment above the handler says drawers stop them). Before, the cursor moved unseen behind the session drawer; with this change the list behind it would also have scrolled, and closing the drawer would have left it somewhere else.
Verification
Measured from the DOM in the isolated preview (mocked IPC, full
Appon the traffic page, about 200 rows), in Chromium and in the system WKWebView (offscreen, the engine Tauri uses on macOS). A probe presses ↑/↓ and after every press checks that the selected row is fully visible (its top not above the pinned header's bottom, its bottom not below the list's, within half a pixel), that the list scrolled only when the row was not already visible and then to exactly that edge, and thatscrollLeftdid not change. Flat and grouped (all sessions expanded), 820×560 and 1100×720, light and dark, starting scrolled fully left, partway and fully right. In WebKit every run walks the whole list down and back up from each of the three starting positions.Before: 30 × ↓ from the top at 1100×720 left the selected row at 1074–1106px in a 682px list that had not scrolled.
After:
scrollLeftThe fractions are rounding: Chromium snaps the scroll offset to device pixels, and WebKit rounds the row's rectangle outward before scrolling, so the row stops up to half a pixel inside the edge. The real keys are CDP key presses in Chromium and
NSEventarrow keys in the WKWebView; they land where the probe's synthetic ones do, so the browser's own arrow-key scrolling stays suppressed.With the session drawer open, 10 real ↓ presses left the list's scroll position and the cursor unchanged (Chromium). After closing it, ↓ moves and scrolls as above.
pnpm typecheck,pnpm test(208 passed) andpnpm buildpass.Not changed here
In the grouped view the cursor still walks
rows(newest first, across all sessions), while each session lists its requests oldest first and collapsed sessions are not rendered. So ↓ can move the highlight up within a session, jump to another session, or land on a row that is not on screen: with the first two sessions collapsed, the first 100 presses highlighted nothing visible. Scrolling now follows whichever row is highlighted; making the traversal follow the on-screen order is a separate change.🤖 Generated with Claude Code