Skip to content

Commit

Permalink
Merge pull request #55 from solid-software/bug/clickable-mistake-with…
Browse files Browse the repository at this point in the history
…-multiline

Bug/Inability set caret cursor with multiline on mobile
  • Loading branch information
solid-danylokhvan authored Jul 6, 2023
2 parents b49555b + 0f91c73 commit 43d2562
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/core/controllers/colored_text_editing_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ class ColoredTextEditingController extends TextEditingController {
if (offset == null) return;

focusNode?.requestFocus();
Future.microtask.call(
() => selection = TextSelection.collapsed(offset: offset),
);
Future.microtask(() => selection = TextSelection.collapsed(offset: offset));

// Find the mistake within the text that corresponds to the offset
final mistake = _mistakes.firstWhereOrNull(
Expand Down Expand Up @@ -287,8 +285,9 @@ class ColoredTextEditingController extends TextEditingController {
text: TextSpan(text: text, style: style),
textDirection: TextDirection.ltr,
);
final textFieldWidth = textFieldRenderBox?.size.width ?? 0;

textPainter.layout();
textPainter.layout(maxWidth: textFieldWidth);

return textPainter.getPositionForOffset(localOffset).offset;
}
Expand Down

0 comments on commit 43d2562

Please sign in to comment.