In my case, it turned out to be a problem with the views getting recycled.
I've implemented a TextField inside a ScrollView with LazyVStack in it, and when keyboard pops up, the scroll view shrinks and TextField leaves a rendering area and becomes unavailable then TextField loses focus.
Switching to VStack solved problem.