fix(memory-graph): popover fallback now picks the side with the most space#1264
Open
abhay-codes07 wants to merge 1 commit into
Open
fix(memory-graph): popover fallback now picks the side with the most space#1264abhay-codes07 wants to merge 1 commit into
abhay-codes07 wants to merge 1 commit into
Conversation
…most space pickBestQuadrant flattened each side's available space to -1 when the popover did not fully fit, then sorted those values for the fallback. Once every side was -1 the sort was meaningless and the fallback always returned right, even for a node hugging the right edge of the container where the left side has ~45x more room. The clamped popover then slides over the node it is annotating. Keep the raw space measurements alongside the required size so the preference pass still checks fit, while the fallback can genuinely rank sides by available space. Also export the helper and cover the preference order, the exact-fit boundary, and the fallback ranking with unit tests.
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.
What
pickBestQuadrantdecides which side of a node the hover popover opens on. When no side fully fits the popover, it's supposed to fall back to the side with the most room — but the fit check flattened each side's measured space to-1before the fallback sort ran:Once every entry is
-1the sort is meaningless and the fallback always answers"right"— even for a node hugging the right edge of a small container where the left side has ~45× more space. The clamping that follows then slides the popover over the node it's annotating.Fix
Keep the raw space measurement alongside the required size for each side. The preference pass (
right → left → below → above) still returns the first side that fully fits — behaviour there is unchanged, including exact-fit boundaries — but the fallback can now genuinely rank sides by available space.The helper is exported so it can be unit-tested directly.
Testing
src/__tests__/popover-quadrant.test.tscover the preference order, the exact-fit boundary, and three fallback scenarios (node hugging the right edge / top / bottom) that the old code all answered with"right"bun run testinpackages/memory-graph— 196 passbun run check-types— clean