Platform: iOS 26 RC / Xcode 26 RC Component: UIKit - UITextField
Description: When typing a Japanese character (or other IME input) as the first character in a UITextField and then losing focus (by pressing Enter or tapping elsewhere), the character is incorrectly duplicated. This issue only happens in iOS26 beta.
Steps to Reproduce:
- Create a UITextField with shouldChangeCharactersIn delegate
- Switch to Japanese keyboard
- Type "あ" (or any hiragana character)
- Press Enter or tap outside the text field
- Observe the character count becomes 2 instead of 1
Expected Result: Character count should remain 1
Actual Result: Character is duplicated, count becomes 2
Sample Code:
func shouldChangeText(
in range: NSRange,
replacementText string: String,
maximumNumberOfCharacters: Int,
regexValidation: String? = nil) -> (String, Bool) {
guard let stringRange = Range(range, in: currentText) else {
return (currentText, false)
}
if let regex = regexValidation,
string != "", // delete key
!string.room.checkPattern(regex) {
return (currentText, false)
}
let changedText = currentText.replacingCharacters(in: stringRange, with: string)
let allowChange = changedText.utf16.count <= maximumNumberOfCharacters
print("=== stringRange: \(stringRange), currentText: \(currentText), replacementText: \(string) changedText: \(changedText), allowChange: \(allowChange) ===")
guard !allowChange else {
return (changedText, allowChange)
}
// Accept text deletion even if changedText count is more than maximumNumberCharacters
guard !string.isEmpty else {
return (changedText, true)
}
insert(text: string, maximumNumberOfCharacters: maximumNumberOfCharacters)
return (currentText, allowChange)
}