Hi, I'm using RxTableViewSectionedAnimatedDataSource to create table view. One of the cells have textview. I subscribe to changes in textview text as follows:
textView.rx.text.orEmpty
.subscribe(onNext: { [weak self] text in
self.viewModel.updateNote(note: text)
})
.disposed(by: disposeBag)
Then, I modify my textview text data in viewModel:
var subject = BehaviorRelay<[EventSectionModel]>.init(value: [])
func updateNote(note: String) {
var newSections = subject.value
if let sectionIndex = newSections.firstIndex(where: { section in
section.items.contains(where: { item in
if case let .typeC(info) = item, info.noteName == noteName {
return true
} else {
return false
}
})
}), let itemIndex = newSections[sectionIndex].items.firstIndex(where: { item in
if case let .typeC(info) = item, info.noteName == noteName {
return true
} else {
return false
}
}) {
var updatedItem = newSections[sectionIndex].items[itemIndex]
if case .typeC(var info) = newSections[sectionIndex].items[itemIndex] {
info.note = note
updatedItem = .typeC(info)
newSections[sectionIndex].items[itemIndex] = updatedItem
subject.accept(newSections)
}
} else {
print("No matching item found")
}
}
The problem is, when I call line bellow my cell with textview is reloaded and it causes keyboard to dismiss.
subject.accept(newSections)
So every time user types a letter, it dismisses keyboard. How to overcome this?
Hi, I'm using RxTableViewSectionedAnimatedDataSource to create table view. One of the cells have textview. I subscribe to changes in textview text as follows:
Then, I modify my textview text data in viewModel:
var subject = BehaviorRelay<[EventSectionModel]>.init(value: [])
The problem is, when I call line bellow my cell with textview is reloaded and it causes keyboard to dismiss.
subject.accept(newSections)
So every time user types a letter, it dismisses keyboard. How to overcome this?
Thanks a lot! Any help/tips are welcome!