Open openradar-mirror opened 5 years ago
Modified: 2019-05-01T10:13:13.008303
Modified: 2019-05-01T10:13:13.008303
Modified: 2019-05-01T10:13:13.008303
Modified: 2019-05-01T10:13:13.008303
Modified: 2019-05-01T10:13:13.008303
Modified: 2019-05-01T10:13:13.008303
Description
Summary: Setting UITextView's
text
property does not usually invoke the delegate methodtextView(_:shouldChangeTextIn:replacementText:)
.This does not appear to be true if the user taps a suggestion on the predictive keyboard. In that case, the delegate method is called twice.
Invocation 1: Invoked in response to the change in the text view. This is expected and is the same behaviour as typing on the keyboard.
Invocation 2: Invoked as part of the
text
setter. This is unwanted behaviour as we intercept replacement text viatextView(_:shouldChangeTextIn:replacementText:)
and set the text property manually. This is currently causing predictive words to appear twice.The docs state "The text view calls this method whenever the user types a new character or deletes an existing character." which leads me to believe the second invocation is unexpected behaviour.
Steps to Reproduce:
Intercept replacement text in
textView(_:shouldChangeTextIn:replacementText:)
and set the text view'stext
property manually before returningfalse
.Tap a word on the predictive toolbar.
Expected Results:
textView(_:shouldChangeTextIn:replacementText:)
invoked once in response to the tap on the predictive toolbar.Actual Results:
textView(_:shouldChangeTextIn:replacementText:)
invoked a second time, on setting thetext
property.- Product Version: iOS 12.2 (16E227) Created: 2019-04-25T15:38:04.319392 Originated: 2019-04-25T00:00:00 Open Radar Link: http://www.openradar.me/50206546