Skip to content

Commit

Permalink
Fix getOffsetToRevealCursor for when cursor is bigger than viewport
Browse files Browse the repository at this point in the history
Fixes #316
  • Loading branch information
Amir-P committed Apr 11, 2024
1 parent 596b61a commit 5cd7e66
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/fleather/lib/src/rendering/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,15 @@ class RenderEditor extends RenderEditableContainerBox
offsetInViewport;
final caretBottom =
endpoints.single.point.dy + kMargin + offsetInViewport;
final caretHeight = caretBottom - caretTop;
double? dy;
if (caretTop < scrollOffset) {
dy = caretTop;
} else if (caretBottom > scrollOffset + viewportHeight) {

/// When caret is bigger than viewport, we reveal it's bottom.
if (caretBottom > scrollOffset + viewportHeight ||
caretHeight > viewportHeight) {
dy = caretBottom - viewportHeight;
} else if (caretTop < scrollOffset) {
dy = caretTop;
}
if (dy == null) return null;
// Clamping to 0.0 so that the content does not jump unnecessarily.
Expand Down

0 comments on commit 5cd7e66

Please sign in to comment.