Skip to content

Flip prompt popover above the cursor when a scroll container would clip it - #1166

Open
shved270189 wants to merge 1 commit into
basecamp:mainfrom
fetlife:fix-prompt-popover-overflow-minimal
Open

Flip prompt popover above the cursor when a scroll container would clip it#1166
shved270189 wants to merge 1 commit into
basecamp:mainfrom
fetlife:fix-prompt-popover-overflow-minimal

Conversation

@shved270189

Copy link
Copy Markdown

Problem

The prompt/mention popover only flips above the cursor when it would overflow the window (popoverRect.bottom > window.innerHeight). When a <lexxy-editor> lives inside a 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 even though the window still has room below it.

Fix

Flip the menu above the cursor when the popover would overflow the editor's nearest clipping ancestor (an ancestor whose computed overflow-y is not visible), capped by the window — instead of checking the window alone:

#availableBottom() {
  let bottom = window.innerHeight
  let node = this.#editorElement

  while (node && node !== document.body && node !== document.documentElement) {
    if (getComputedStyle(node).overflowY !== "visible") {
      bottom = Math.min(bottom, node.getBoundingClientRect().bottom)
    }
    node = node.parentElement
  }

  return bottom
}

When the editor has no clipping ancestor the bound is window.innerHeight, so an ordinary editor keeps the menu below the cursor exactly as before — the flip only kicks in when something would actually clip it.

Tests

New test/browser/tests/prompts/overflow_container.test.js + fixture, covering both directions:

  • editor inside a fixed-height scroll container with the window still having room below → menu flips above the cursor and stays within the container;
  • the same editor with no clipping ancestor → menu stays below the cursor (guards against flipping when nothing clips).

Both new tests pass on chromium, firefox, and webkit; the full prompts suite passes on chromium.

@shved270189
shved270189 marked this pull request as ready for review June 24, 2026 16:08
Copilot AI review requested due to automatic review settings June 24, 2026 16:08

@claude claude Bot 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.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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