ReactiveX / RxSwift

Reactive Programming in Swift
MIT License
24.34k stars 4.17k forks source link

Whenever textDidEndEditing is called, UISearchBar.rx.text is always called #1916

Closed aki-mizu closed 5 years ago

aki-mizu commented 5 years ago

Short description of the issue:

Due to changes related to #1714, it seems now searchBar.rx.textDidEndEditing will always trigger UISearchBar.rx.text. When there's some text in the search bar and if user goes back to previous screen or goes to another screen, and if there is keyboard on the screen, UISearchBar.rx.text will always be invoked.

Expected outcome:

UISearchBar.rx.text should only be invoked if there is changes in the UISearchBar text.

What actually happens:

Whenever viewWillDIsappear is called, if there is keyboard on the screen, textDidEndEditing will be called, accordingly UISearchBar.rx.text will be called.

Self contained code example that reproduces the issue:

It can we reproduced using the RxExample in the RxSwift repo. step 1: tap GitHub Search Repository step 2: type some keyword step 3: wait for response from Github API step 4: Tap Back button You can see activity indicator will be turned on.

RxSwift/RxCocoa/RxBlocking/RxTest version/commit

It only happens in version 4.4.0 and later after commit 78c500c

Platform/Environment

How easy is to reproduce? (chances of successful reproduce after running the self contained code)

Xcode version:

XCode 10.2

:warning: Fields below are optional for general issues or in case those questions aren't related to your issue, but filling them out will increase the chances of getting your issue resolved. :warning:

Installation method:

I have multiple versions of Xcode installed: (so we can know if this is a potential cause of your issue)

Level of RxSwift knowledge: (this is so we can understand your level of knowledge and formulate the response in an appropriate manner)

kzaher commented 5 years ago

Hi @darlhz ,

Yep, there is no guarantees in the API that you will only get called with unique values. We do the same of UITextField.

In the case of UITextField it's even more complicated because autocorrect can change the content.

We can't add if != oldValue in the extension because you could have programatic update to text field which we can't detect, and then a valid update with the same value.

If you have some concrete proposal, please make a PR and we can review it.

RxExample is just an example project. If you would like to improve that case for our example, feel free to make a PR.

ivanglushko commented 3 years ago

Thanks thought this was a bug 😅