ios – The way to stop bizarre animation with footer button and keyboard in SwiftUI


I’ve this bizarre SwiftUI keyboard animation bug that’s at the moment reside in certainly one of my apps and I’m struggling to repair it and would respect any assist in understanding the underlying downside and learn how to clear up it.

Under is instance code made up of easy view that comprises a TextField and a Footer Button. I set the TextField to get focus after 0.75 seconds when the view seems.

Sadly, the beneath code leads to an animation bug the place the background behind the footer button flashes briefly because the keyboard finishes animating on to the display screen.

struct NameTextFieldView: View {
    @Surroundings(.dismiss) var dismiss
    @FocusState non-public var isFocused: Bool
    @State non-public var identify: String = ""
    var physique: some View {
        NavigationStack {
            Kind {
                TextField("Identify", textual content: $identify)
                    .onAppear {
                        DispatchQueue.major.asyncAfter(deadline: .now() + 0.75) {
                          isFocused = true
            .safeAreaInset(edge: .backside) {
                Button(motion: {
                }, label: {
                    Textual content("Add")
                .body(width: 200, top: 44)
                .clipShape(RoundedRectangle(cornerSize: CGSize(width: 20, top: 10)))
            .navigationTitle("Add Identify")

Odd animation bug.

animation bug