Skip to content

fix(memory-graph): center arrow-key navigation in the visible graph area#1337

Open
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:fix/graph-nav-center-height
Open

fix(memory-graph): center arrow-key navigation in the visible graph area#1337
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:fix/graph-nav-center-height

Conversation

@abhay-codes07

Copy link
Copy Markdown
Contributor

Problem

viewport.centerOn(worldX, worldY, width, height) positions the target point at height / 2 on screen:

this.targetPanY = height / 2 - worldY * this.zoom

The component derives a separate graphFitHeight that, on compact viewports, reserves room for the bottom control bar:

const graphFitHeight = isCompactViewport
  ? Math.max(containerSize.height - 170, 240)
  : containerSize.height

Auto-fit, the center button, and the zoom controls all pass graphFitHeight, so they place content in the middle of the visible graph area. But selectAndCenter (arrow-key node navigation) passed the full containerSize.height:

viewportRef.current.centerOn(n.x, n.y, containerSize.width, containerSize.height)

So on mobile, stepping through nodes with the keyboard centers the selected node at the midpoint of the whole container, which puts it partly behind the bottom controls, while the dedicated center button drops the same graph correctly above them.

Fix

Pass graphFitHeight (and depend on it) so selectAndCenter lands the node where the other centering paths already do:

viewportRef.current.centerOn(n.x, n.y, containerSize.width, graphFitHeight)

On desktop graphFitHeight === containerSize.height, so nothing changes there. Full memory-graph suite (188 tests) passes and tsc --noEmit is clean.

selectAndCenter passed the full containerSize.height to viewport.centerOn,
while every other navigation action (auto-fit, center, zoom) uses
graphFitHeight, which on compact viewports subtracts the space taken by the
bottom controls. centerOn places the target at height/2, so keyboard
navigation dropped the selected node at the midpoint of the whole container,
partly behind the bottom control bar on mobile, instead of the midpoint of the
visible graph area like the center button does. Use graphFitHeight so
arrow-key selection lands where the other centering paths already do.
Copilot AI review requested due to automatic review settings July 22, 2026 11:54

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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