Skip to content

Commit cd363b5

Browse files
authored
Fix floating cursor position issue by fixing getLocalRectForCaret (#491)
1 parent 3609b65 commit cd363b5

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

packages/fleather/lib/src/rendering/editor.dart

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,17 +187,7 @@ class RenderEditor extends RenderEditableContainerBox
187187
markNeedsSemanticsUpdate();
188188
}
189189

190-
Offset get paintOffset {
191-
final double dx;
192-
if (padding is EdgeInsets) {
193-
dx = (padding as EdgeInsets).left;
194-
} else if (padding is EdgeInsetsDirectional) {
195-
dx = (padding as EdgeInsetsDirectional).start;
196-
} else {
197-
dx = 0.0;
198-
}
199-
return Offset(-dx, -offset.pixels);
200-
}
190+
Offset get paintOffset => Offset(0.0, -offset.pixels);
201191

202192
ViewportOffset get offset => _offset;
203193
ViewportOffset _offset;
@@ -762,8 +752,8 @@ class RenderEditor extends RenderEditableContainerBox
762752
final childLocalRect = targetChild.getLocalRectForCaret(localPosition);
763753

764754
final boxParentData = targetChild.parentData as BoxParentData;
765-
return childLocalRect
766-
.shift(Offset(0, boxParentData.offset.dy + paintOffset.dy));
755+
return childLocalRect.shift(Offset(
756+
resolvedPadding!.left, boxParentData.offset.dy + paintOffset.dy));
767757
}
768758

769759
// Start floating cursor

0 commit comments

Comments
 (0)