Skip to content

Conversation

@Renzo-Olivares
Copy link
Contributor

@Renzo-Olivares Renzo-Olivares commented Aug 22, 2024

Fix a crash when deleting text in an EditableText inside CupertinoPageRoute, with a CJK keyboard on Android. CJK Keyboards on Android may send a key event instead of directly updating the text through the IME, in that case we do not hide the toolbar when text is deleted. This causes an exception when in scrollable text, because the context menu scroll listener tries to access the RenderBox.size while in a weird state. This change fixes that and hides the toolbar when text is deleted through a key event.

Fixes #153949

Cherry-pick of: #153822

Related issue: #153003

…rtinoPageRoute` throws exception (flutter#153822)

Fixes flutter#153003

Pressing backspace on CJK keyboards to delete text may trigger a key event which in turns triggers the `DeleteTextIntent`. This is different than English keyboards where the updated `TextEditingValue` from the `TextInputPlugin` will come through `updateEditingValue` which allows us to hit the codepath that hides the text selection toolbar. https://github.com/flutter/flutter/blob/23883b13d4919bed4f572e78cb60c016bb3b872f/packages/flutter/lib/src/widgets/editable_text.dart#L3245-L3250 Because CJK keyboards may not hit this codepath, when the text is long and editable text tries to bring the new selection into view by scrolling, this triggers the hide context menu scroll listener in a weird state https://github.com/flutter/flutter/blob/23883b13d4919bed4f572e78cb60c016bb3b872f/packages/flutter/lib/src/widgets/editable_text.dart#L3865-L3869 causing an exception to be thrown.

This PR tries to work around the issue above by hiding the toolbar when a `DeleteTextIntent` is received.
@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. labels Aug 22, 2024
@Renzo-Olivares Renzo-Olivares marked this pull request as ready for review August 22, 2024 17:26
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CP LGTM 👍

@reidbaker reidbaker added the cp: review Cherry-picks in the review queue label Aug 26, 2024
@reidbaker reidbaker added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 26, 2024
@auto-submit auto-submit bot merged commit bc7fd79 into flutter:flutter-3.24-candidate.0 Aug 26, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 4, 2024
…rd while in CupertinoPageRoute throws exception (#153822) (flutter/flutter#153946)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 4, 2024
…rd while in CupertinoPageRoute throws exception (#153822) (flutter/flutter#153946)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App cp: review Cherry-picks in the review queue framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants