Skip to content

Fix/selection context menu out of view#2739

Open
Alspb wants to merge 2 commits into
singerdmx:masterfrom
Alspb:fix/selection-context-menu-out-of-view
Open

Fix/selection context menu out of view#2739
Alspb wants to merge 2 commits into
singerdmx:masterfrom
Alspb:fix/selection-context-menu-out-of-view

Conversation

@Alspb

@Alspb Alspb commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Description

The selection (Cut/Copy/Paste) context menu could be positioned off-screen,
so it didn't appear, whenever the selection extended beyond the visible
viewport. This PR clamps the menu's anchors into the editor's visible region so it
stays reachable — matching a native multiline TextField.

Type of Change

  • Feature: New functionality without breaking existing features.
  • 🛠️ Bug fix: Resolves an issue without altering current behavior.
  • 🧹 Refactor: Code reorganization, no behavior change.
  • Breaking: Alters existing functionality and requires updates.
  • 🧪 Tests: New or modified tests
  • 📝 Documentation: Updates or additions to documentation.
  • 🗑️ Chore: Routine tasks, or maintenance.
  • Build configuration change: Build/configuration changes.

Copilot AI review requested due to automatic review settings June 8, 2026 06:54

Copilot AI 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.

Pull request overview

This PR fixes cases where the selection context menu (Cut/Copy/Paste) could be positioned off-screen when a selection extends beyond the visible editor viewport by clamping the context-menu anchor points into the visible region (aiming to match native multiline TextField behavior).

Changes:

  • Clamp contextMenuAnchors to the editor’s visible viewport region to keep the selection toolbar on-screen.
  • Adjust selectAll() toolbar-driven behavior (currently adds a deterministic scroll to the top).
  • Update CHANGELOG.md with an entry describing the fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/src/editor/raw_editor/raw_editor_state.dart Adds viewport-aware clamping for selection context-menu anchors (and includes a toolbar selectAll() scroll behavior change).
CHANGELOG.md Documents the context-menu off-screen fix under “Unreleased / Fixed”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +169 to 175
if (cause == SelectionChangedCause.toolbar && scrollController.hasClients) {
// Reveal the start of the selection (the top of the document) with a
// single deterministic scroll. The post-frame `_showCaretOnScreen`
// also reveals the selection start (`endpoints.first`) bug does this
// with a lag.
scrollController.jumpTo(scrollController.position.minScrollExtent);
}
Comment on lines 262 to +273
TextSelectionToolbarAnchors get contextMenuAnchors {
final glyphHeights = _getGlyphHeights();
final selection = textEditingValue.selection;
final points = renderEditor.getEndpointsForSelection(selection);
return TextSelectionToolbarAnchors.fromSelection(
final anchors = TextSelectionToolbarAnchors.fromSelection(
renderBox: renderEditor,
startGlyphHeight: glyphHeights.startGlyphHeight,
endGlyphHeight: glyphHeights.endGlyphHeight,
selectionEndpoints: points,
);
return _clampAnchorsToVisibleViewport(anchors);
}
Comment on lines +396 to +401
renderBoxForBounds: () =>
context
.findAncestorStateOfType<QuillEditorState>()
?.context
.findRenderObject()
as RenderBox?,
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