Add paintSelectionBehindText configuration option #2604
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.
Fix: Web platform text selection scroll jumping + Feature: Configurable selection paint order
1. Web Platform Scroll Jumping Issue Description
On web platform, when performing text selection by dragging (especially with long documents), the scroll behavior becomes erratic and jumpy. The viewport constantly jumps back to the selection start position, making it nearly impossible to select text upwards or across long distances.
2. Selection Readability Issue
Text selection highlighting was always painted in front of text, requiring transparent selection colors which could make selected text hard to read with certain color combinations.
Root Causes
Scroll Issue
The problem was in the caretTextPosition getter in RenderEditor class. During drag selection, it always returned selection.extent (the current drag position), causing the scroll mechanism to constantly try to bring the moving selection end into view, resulting in conflicting scroll behaviors.
Selection Paint Order
The selection highlighting was hardcoded to paint in front of text, limiting flexibility for different UI preferences and readability requirements.
Solutions Implemented
1. Intelligent Scroll Behavior for Web Platform
Enhanced QuillController with drag state management:
Updated RenderEditor to use controller's smart caret positioning:
Updated selection handling to properly track drag lifecycle:
2. Configurable Selection Paint Order
Added paintSelectionBehindText boolean field to control rendering order:
Implementation details:
Usage
Scroll Fix (Automatic)
Selection Paint Order Configuration
Benefits
Scroll Fix
Selection Paint Order
Testing
Scroll Fix
Selection Paint Order