From 5cd7e665eda999ef6c9e795e08a3191cd29bf37d Mon Sep 17 00:00:00 2001 From: Amir Panahandeh Date: Thu, 11 Apr 2024 16:22:35 +0330 Subject: [PATCH] Fix getOffsetToRevealCursor for when cursor is bigger than viewport Fixes #316 --- packages/fleather/lib/src/rendering/editor.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/fleather/lib/src/rendering/editor.dart b/packages/fleather/lib/src/rendering/editor.dart index 27a8ab34..0966a10f 100644 --- a/packages/fleather/lib/src/rendering/editor.dart +++ b/packages/fleather/lib/src/rendering/editor.dart @@ -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.