I’ve run into a wierd conduct and hoping somebody may help me perceive why it’s occurring so I can keep away from issues like this sooner or later. I’ve acquired a sophisticated View however I’ve stripped it alllll the way in which down so far as I can whereas nonetheless demonstrating the issue/bug/no matter, and I’ve included that beneath.
The actual view has a ZStack with a VStack and a Grid, and so forth, however I’ve stripped all of it out till I acquired all the way down to this.
// stripped down model of the view
struct DebugWTF: View {
@State var debugstring: String = ""
var physique: some View {
ScrollView {
GeometryReader { geometry in
TextField("placeholder_eg", textual content: $debugstring)
}
}
}
}
I’ve found that if I modify the ordering of the containers, then the TextField() begins working usually.
var physique: some View {
ScrollView {
GeometryReader { geometry in
TextField(...) // is NOT tappable
}
}
}
then my TextField() can’t be tapped on. Nevertheless it DOES work if I swap these:
var physique: some View {
GeometryReader { geometry in
ScrollView {
TextField(...) // IS tappable
}
}
}
When that labored, I believed perhaps the ScrollView was behaving unusually if its direct little one was the GeometryReader, however even when I insert a ZStack between them, the TextField() shouldn’t be tappable once more:
var physique: some View {
ScrollView {
ZStack {
GeometryReader { geometry in
TextField(...) // is NOT tappable
}
}
}
}
Can anybody clarify why the ordering of those is inflicting an issue? I might like to grasp what’s basically occurring in order that I can perceive how one can keep away from such issues sooner or later.