Skip to content

Commit

Permalink
Fix: reporting IME geometry crashes when is true in SuperEditor, care…
Browse files Browse the repository at this point in the history
…t doesn't blink when placed by 'autofocus' in SuperEditor (Resolves #1566) (#1575)
  • Loading branch information
matthew-carroll authored Oct 28, 2023
1 parent e63d479 commit 6e2040f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class SuperEditorIosControlsController {

/// Whether the caret (collapsed handle) should blink right now.
ValueListenable<bool> get shouldCaretBlink => _shouldCaretBlink;
final _shouldCaretBlink = ValueNotifier<bool>(false);
final _shouldCaretBlink = ValueNotifier<bool>(true);

/// Tells the caret to blink by setting [shouldCaretBlink] to `true`.
void blinkCaret() => _shouldCaretBlink.value = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,12 @@ class SuperEditorImeInteractorState extends State<SuperEditorImeInteractor> impl
return;
}

_reportSizeAndTransformToIme();
_reportCaretRectToIme();
_reportTextStyleToIme();
final myRenderBox = context.findRenderObject() as RenderBox?;
if (myRenderBox != null && myRenderBox.hasSize) {
_reportSizeAndTransformToIme();
_reportCaretRectToIme();
_reportTextStyleToIme();
}

// There are some operations that might affect our transform, size and the caret rect,
// but we can't react to them.
Expand Down
3 changes: 2 additions & 1 deletion super_editor/lib/src/default_editor/super_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ class SuperEditorState extends State<SuperEditor> {
editor: widget.editor,
document: widget.document,
selection: _composer.selectionNotifier,
isDocumentLayoutAvailable: () => _docLayoutKey.currentContext != null,
isDocumentLayoutAvailable: () =>
(_docLayoutKey.currentContext?.findRenderObject() as RenderBox?)?.hasSize == true,
getDocumentLayout: () => editContext.documentLayout,
placeCaretAtEndOfDocumentOnGainFocus: widget.selectionPolicies.placeCaretAtEndOfDocumentOnGainFocus,
restorePreviousSelectionOnGainFocus: widget.selectionPolicies.restorePreviousSelectionOnGainFocus,
Expand Down

0 comments on commit 6e2040f

Please sign in to comment.