Hey guyz...! Has anyone faced such issue with Basi...
# compose-ios
k
Hey guyz...! Has anyone faced such issue with BasicTextField in lazycolumn? I have tried setting onFocusBehaviour to nothing but it didn't effect. kotlin:- 1.9.10 Compose:- 1.5.11
u
This happening only on iOS or Android as well?
k
Only on iOS
u
I’m facing something similar. What happens when you select text suggestion from keyboard?
k
it simply ads the suggestion.
u
can you share the code where you are handling onValueChange?
k
fun updateQuery(query: String) {
_query._update_ *{* query *}*
if (query._isEmpty_())
resetStates()
}
I am updating it via viewmodel...
_query is mutableStateFlow in viewmodel...
u
Possible that _query has older value persisting while typing in new value?
k
Doesn't happen, I
I'm collecting query as state and using it as value on textfield and it gets updated in viewmodel with update closure.
m
@Khanzada Kashif check if your method responsible for updating state in viewModel is running async (i.e. in some coroutine). The compose text field is having issues when it is updated from separate thread. The workaround is to A) save text state in a composable B) run text processing in vm synchronously
Also those issues will be presumably fixed with
BasicTextField2
. See https://proandroiddev.com/basictextfield2-a-textfield-of-dreams-1-2-0103fd7cc0ec
k
I've debugged it found that issue is occurring due to manually hiding keyboard when user hits the search action.
👀 1
@Mikolaj
m
Oh that is interesting.. glad that You found it 🙌
k
But, Haven't found the solution for it yet... 😄
@Mikolaj That's how it is happening. If i remove the hide call, keyboard doesn't go down neither does the view flickers.
m
oh maybe You can try the FocusManager instead of keyboard controller?
Copy code
val focusManager = LocalFocusManager.current
// in your KeyboardActions
focusManager.clearFocus(force = true)
It should clear the focus off the text field and hide the keyboard 🤞
k
yep, tried it and it does hide the keyboard, but view still flickers.
🫤 1
o
This looks like a problem with IME insets to me 🤔 Does your
ContentView
has
ignoresSafeArea
as in example? https://github.com/JetBrains/compose-multiplatform-template/blob/main/iosApp/iosApp/ContentView.swift
k
@Oleksandr Balan Thanks bro, you a life saver... 😍 adding ignoreSafeArea worked,
fist bump 2