mirror of
https://github.com/yattee/yattee.git
synced 2025-11-22 06:31:26 +00:00
Fix iPad iOS 18 keyboard dismissal issue in search
Removed auto-focus logic that was causing keyboard show/hide loop on iPad with docked keyboard. The keyboard was repeatedly dismissing immediately after appearing due to interaction between keyboard notifications, focus state changes, and view updates. Changes: - Removed focused state and keyboard observer from SearchModel - Removed iOS textField reference (kept macOS only) - Removed auto-focus logic from FocusableSearchTextField on iOS - Cleaned up unused focus-related code The search field now works reliably when tapped manually on iPad. Auto-focus still works on macOS where it doesn't cause issues.
This commit is contained in:
@@ -318,7 +318,7 @@ final class NavigationModel: ObservableObject {
|
||||
func multipleTapHandler() {
|
||||
switch tabSelection {
|
||||
case .search:
|
||||
search.focused = true
|
||||
break
|
||||
default:
|
||||
print("not implemented")
|
||||
}
|
||||
|
||||
@@ -16,13 +16,9 @@ final class SearchModel: ObservableObject {
|
||||
@Published var querySuggestions = [String]()
|
||||
private var suggestionsDebouncer = Debouncer(.milliseconds(200))
|
||||
|
||||
@Published var focused = false
|
||||
|
||||
@Default(.showSearchSuggestions) private var showSearchSuggestions
|
||||
|
||||
#if os(iOS)
|
||||
var textField: UITextField!
|
||||
#elseif os(macOS)
|
||||
#if os(macOS)
|
||||
var textField: NSTextField!
|
||||
#endif
|
||||
|
||||
@@ -30,15 +26,9 @@ final class SearchModel: ObservableObject {
|
||||
private var resource: Resource!
|
||||
|
||||
init() {
|
||||
#if os(iOS)
|
||||
addKeyboardDidHideNotificationObserver()
|
||||
#endif
|
||||
}
|
||||
|
||||
deinit {
|
||||
#if os(iOS)
|
||||
removeKeyboardDidHideNotificationObserver()
|
||||
#endif
|
||||
}
|
||||
|
||||
var isLoading: Bool {
|
||||
@@ -158,18 +148,4 @@ final class SearchModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
private func addKeyboardDidHideNotificationObserver() {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(onKeyboardDidHide), name: UIResponder.keyboardDidHideNotification, object: nil)
|
||||
}
|
||||
|
||||
@objc func onKeyboardDidHide() {
|
||||
focused = false
|
||||
}
|
||||
|
||||
private func removeKeyboardDidHideNotificationObserver() {
|
||||
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardDidHideNotification, object: nil)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user