Open
Description
Description
Hi,
it seems there's a nasty edge case when using introspection on TextFields or TextViews within conditionals:
import SwiftUI
import SwiftUIIntrospect
struct ContentView: View {
@State private var isShown: Bool = false
@FocusState private var textFieldFocused
@State private var textFieldContent = ""
var body: some View {
Form {
Toggle("Show Keyboard", isOn: $isShown)
if isShown {
TextField("title", text: $textFieldContent, axis: .vertical)
.introspect(.textEditor, on: .iOS(.v18), customize: { textView in
let view = UIView()
view.backgroundColor = .red
view.frame = .init(origin: .zero, size: .init(width: 200, height: 100))
textView.backgroundColor = .red
textView.inputView = view
})
.onAppear {
textFieldFocused = true
}
.focused($textFieldFocused)
}
}
}
}
The code above shows that the introspection sets the background color of the textView nicely, but the inputView only receives the right inputView after toggling the flag a second time to true.
Do you have any idea why that could be happening and whether this is solveable?
Kind regards!
Checklist
- I have read the README before submitting this report.
- This issue hasn't been addressed in an existing GitHub issue or discussion.
Expected behavior
No response
Actual behavior
No response
Steps to reproduce
No response
Version information
1.3.0
Destination operating system
iOS18
Xcode version information
Xcode 16.0
Swift Compiler version information
No response