Different behavior of FocusState on iOS 17

Hi, I have a problem adding a field to the application where the user enters formatted text and has the ability to delete it when focused.

Interestingly, the application behaves correctly on iOS 17, and pressing 'x button' while typing deletes the text. However, on lower iOS versions, nothing happens and text doesn't disappear.

First gif (iOS 15.5) second (iOS 17.2) and here is my code.

import SwiftUI

struct ContentView: View {
    @FocusState var isFocused: Bool
    
    @State var text = 0
    var body: some View {
        VStack {
            HStack {
                TextField("write text here...",
                          value: $text,
                          format: .number)
                .focused($isFocused)
                .keyboardType(.numberPad)
                
                if isFocused {
                    Button("",
                           systemImage: "xmark.circle.fill") {
                        text = 0
                    }
                }
            }
            .border(.black)
        }
        .padding()
    }
}

Does anyone know what's going on and how to make the application work on all iOS versions the way it does on 17?

Different behavior of FocusState on iOS 17
 
 
Q