Flip prompt popover above the cursor when a scroll container would clip it - #5
Draft
shved270189 wants to merge 1 commit into
Draft
Flip prompt popover above the cursor when a scroll container would clip it#5shved270189 wants to merge 1 commit into
shved270189 wants to merge 1 commit into
Conversation
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.
Problem
The prompt/mention popover only flips above the cursor when it overflows the window (
popoverRect.bottom > window.innerHeight). When a<lexxy-editor>lives inside a host container that clips overflow — e.g. a fixed-height scroll area or modal composer — the menu opens downward and is cut off by that container while the window still has room below.Fix
Decide the flip against the editor's nearest clipping ancestor (the lowest visible bottom among ancestors whose
overflow-yisn'tvisible), capped by the window, instead of the window alone. On a plain page there is no clipping ancestor, so the bound iswindow.innerHeightand behaviour is unchanged.Comparing against
contentRect.bottomwould regress the common case:.lexxy-editor__contentgrows with content and has nooverflow/max-height, so a downward menu on the last line always exceeds it and would flip up on a normal page. Walking to the real clipping ancestor avoids that.Also in this change:
data-clipped-at-bottomwhen the menu fits below again — the flip is re-evaluated from state-independent geometry on each reposition, so it toggles both ways without oscillating.visualViewportresize (rAF-throttled) so a pinned menu stays correctly placed as the editor scrolls or the viewport changes.Tests
New
test/browser/tests/prompts/overflow_container.test.js+ fixture: an editor inside a fixed-height scroll container with window room below. Verifies the menu flips above and stays within the container, and that the flip clears once the container has room again. Both assertions fail against the old window-only check.Full prompts suite passes on chromium/firefox/webkit (the pre-existing macOS
cursor_moves_awayEnd-key failure is unaffected).