Japanese Text remains in SwiftUI TextField after clearing the bound String

1 day ago 4
ARTICLE AD BOX

I am experiencing an issue where Japanese Hiragana characters remain visible in a TextField even after the underlying @Binding string is set to empty.

Type Hiragana characters into the TextField.

Press "Done" to confirm the input.

Tap the "X" button which executes text = "".

The text remains visible in the TextField, although the @Binding value itself is empty.

Interestingly, this only happens with Hiragana. If I convert the text to Kanji or Katakana before clearing, it disappears as expected.

The text I deleted is still showing.

Environment:

Xcode 26.2

iOS 26.2

Minimal Reproducible Example

import SwiftUI struct UserSearchField: View { @Binding var text: String let placeholder: String @FocusState private var isFocused: Bool var body: some View { HStack(spacing: 8) { Image(systemName: "magnifyingglass") .font(.system(size: 14)) .foregroundStyle(.gray) .padding(.leading, 12) ZStack(alignment: .leading) { if text.isEmpty { Text(placeholder) .foregroundStyle(.gray) } TextField("", text: $text) .font(.body) .foregroundStyle(.primary) .focused($isFocused) .submitLabel(.done) } if !text.isEmpty { Button { // This should clear the text, but Hiragana persists text = "" } label: { Image(systemName: "xmark.circle.fill") .foregroundStyle(.gray) } .padding(.trailing, 12) } } .frame(height: 44) .background( RoundedRectangle(cornerRadius: 8) .fill(Color(.systemBackground)) ) .overlay( RoundedRectangle(cornerRadius: 8) .stroke(Color.gray.opacity(0.4), lineWidth: 1) ) } } struct ContentView: View { @State private var searchText = "" var body: some View { NavigationStack { VStack(spacing: 24) { Text("Searcher") .font(.headline) UserSearchField( text: $searchText, placeholder: "Search by keyword" ) Text("Result: \(searchText)") .font(.caption) .foregroundStyle(.secondary) Spacer() } .padding() .navigationTitle("Home") } } } #Preview { ContentView() }

Question:

Is there a way to programmatically force the TextField to flush the IME buffer without manually toggling focus, or is this a known SwiftUI bug?

Read Entire Article