lionheart / openradar-mirror

A mirror of radars pulled from http://openradar.me/.
245 stars 17 forks source link

50206546: UITextView unexpectedly calls `textView(_:shouldChangeTextIn:replacementText:)` on setting `text` property #21213

Open openradar-mirror opened 5 years ago

openradar-mirror commented 5 years ago

Description

Summary: Setting UITextView's text property does not usually invoke the delegate method textView(_: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 via textView(_: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:

  1. Intercept replacement text in textView(_:shouldChangeTextIn:replacementText:) and set the text view's text property manually before returning false.

  2. 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 the text 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

openradar-mirror commented 5 years ago

Modified: 2019-05-01T10:13:13.008303

openradar-mirror commented 5 years ago

Modified: 2019-05-01T10:13:13.008303

openradar-mirror commented 5 years ago

Modified: 2019-05-01T10:13:13.008303

openradar-mirror commented 5 years ago

Modified: 2019-05-01T10:13:13.008303

openradar-mirror commented 5 years ago

Modified: 2019-05-01T10:13:13.008303

openradar-mirror commented 5 years ago

Modified: 2019-05-01T10:13:13.008303