Fix: cap context menu height so it doesn't render off-screen - #1786
Open
julcap wants to merge 1 commit into
Open
Fix: cap context menu height so it doesn't render off-screen#1786julcap wants to merge 1 commit into
julcap wants to merge 1 commit into
Conversation
The per-node context menu (Type/Insert/Duplicate/Remove, and the append-node menu) is created without `limitHeight`, unlike the TreePath breadcrumb menu which already passes `limitHeight: true` (see TreePath.js). Without it, ContextMenu.show() can pick "show below" as a fallback even when there isn't enough room in either direction, and the menu's own height is never capped - so in an editor embedded in a size-constrained container, the bottom items of the menu render past the container's edge and are unreachable. Passing `limitHeight: true` (mirroring TreePath.js) caps the menu's list height to the actually available space and adds an internal scrollbar, so it always renders fully inside the frame instead of being cut off. Related to josdejong#571.
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
The per-node context menu (Type / Insert / Duplicate / Remove) and the append-node menu are constructed without
limitHeight:TreePath.js's breadcrumb menu already opts into this:Without it,
ContextMenu.show()can fall back to "show below" even when neither direction has enough room, and the menu's own height is never capped. In an editor embedded in a size-constrained container (e.g. a small panel, an iframe, a modal), this means the bottom items of the menu (typically Duplicate/Remove) render past the container's edge and become unreachable - there's no scrollbar, they're just cut off.This is the same underlying gap described in #571 for the general "popups can't overflow the editor" case, specifically for the per-node context menu, which never got the
limitHeighttreatmentTreePath.jsalready has.Change
Pass
limitHeight: truein both placesContextMenuis constructed for per-node menus (src/js/Node.js,src/js/appendNodeFactory.js), mirroring the existingTreePath.jsusage. This caps the menu's list height to the actually-available space and adds an internal scrollbar (both handled already insideContextMenu.show()whenlimitHeightis set), so the menu always renders fully inside the frame instead of being clipped.Testing
npm run lintpasses.ContextMenu.show()collision-detection logic, which already implements the height-limiting behavior forTreePath.js's menu - this change only extends the same, already-proven option to the two other call sites.Related to #571.