Fix context submenus overflowing past the bottom edge - #1666
Open
LuisMend12 wants to merge 4 commits into
Open
Conversation
…o test Submenus near the bottom of the viewport could render past the bottom edge because they anchor via `bottom: -50%` off their parent button (ContextSubMenu.razor.css) and only the top-overflow case was corrected. Adds the missing bottom-edge check and pulls the shared correction math into an exported computeSubmenuTranslate() so it's unit-testable without a DOM, plus a demo/regression test covering all four edges (Valour-Software#1622).
SigmaTel71
reviewed
Aug 22, 2026
Drop issue-number references and the redundant "why this is tested" comment above computeSubmenuTranslate.
SigmaTel71
reviewed
Aug 22, 2026
Comment on lines
+24
to
+25
| // Margin kept between a repositioned submenu and the viewport edge. | ||
| const SUBMENU_EDGE_MARGIN = 10; |
Member
There was a problem hiding this comment.
I think it's too much to have a dedicated constant for someting used only once.
Co-authored-by: Vitaly Orekhov <vkvo2000@vivaldi.net>
Co-authored-by: Vitaly Orekhov <vkvo2000@vivaldi.net>
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.
Summary
#1622was fixed for the top/right edges in Fix context menu boundary handling #1662, but submenus anchor viabottom: -50%off their parent button (ContextSubMenu.razor.css), so a button near the bottom of the viewport can still open a submenu whose content extends past the bottom edge. This adds the missing bottom-edge check, mirroring the existing right-edge and top-edge corrections.reposition()into an exported, purecomputeSubmenuTranslate(boundingBox, windowWidth, windowHeight, margin)so it can be unit tested without a DOM/browser.Test plan
Valour/Tests/Js/context-menu-reposition.test.mjs(node --test) covering: no correction when in bounds, right-edge overflow, top-edge overflow, the new bottom-edge overflow case, simultaneous right+bottom overflow, top-takes-precedence-over-bottom, and a custom margin.node --test Valour/Tests/Js/*.test.mjs— all 61 tests pass (54 pre-existing + 7 new).