commit 62e3b387afa076f761f8d2e69ca1c95d1f19d94b
parent 3b738aa61aa6bfe68204e1014459c309c4970eff
Author: Michael Camilleri <[email protected]>
Date: Thu, 5 Mar 2026 01:59:48 +0900
Fix first responder resignation for certain tasks
On iPadOS, the focused active task was not resigning its first responder
status properly. This commit fixes that.
Co-Authored-By: Claude 4.6 Opus <[email protected]>
Diffstat:
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/ListlessiOS/Helpers/TappableTextField.swift b/ListlessiOS/Helpers/TappableTextField.swift
@@ -119,11 +119,18 @@ struct TappableTextField: UIViewRepresentable {
) -> Bool {
guard text == "\n" else { return true }
// Intercept Return: trigger new-task creation without inserting a newline.
- // Return false keeps the text view as first responder, matching the UITextField
- // behaviour where textFieldShouldReturn returned false — SwiftUI then
- // transfers first responder atomically in the same render pass.
returnKeyPressed = true
onEditingChanged(false, true)
+ if textView.returnKeyType == .done {
+ // Non-last task (or empty title): resign immediately so SwiftUI's
+ // focus binding update reliably clears the field on iPad, where the
+ // deferred focusedFieldBinding = .scrollView alone doesn't resign
+ // the UITextView through the hardware-keyboard focus system.
+ textView.resignFirstResponder()
+ }
+ // Return false: for .next (last active task with text), the text view
+ // stays first responder so SwiftUI can transfer focus atomically to the
+ // newly created task's text field in the same render pass.
return false
}
}