Prechádzať zdrojové kódy

Clear job search results when refocusing the keywords field

When the user clicks or tabs back into the job search field after a
search, remove prior result cards and the empty-state message so the
listing area resets for a new query. Keywords are preserved. Home
reset reuses the same listing-clear helper.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 2 mesiacov pred
rodič
commit
00f77a6e74
1 zmenil súbory, kde vykonal 12 pridanie a 4 odobranie
  1. 12 4
      App for Indeed/Views/DashboardView.swift

+ 12 - 4
App for Indeed/Views/DashboardView.swift

@@ -543,16 +543,21 @@ final class DashboardView: NSView, NSTextFieldDelegate {
         }
     }
 
-    /// Restores the main job-search experience: cleared query and no listings until the user searches again.
-    private func applyHomeState() {
-        jobKeywordsField.stringValue = ""
+    /// Removes result cards or the “no matches” message so a new search starts from a blank listing area.
+    private func clearJobSearchResultsUI() {
         configureJobListings([], noResultsForQuery: nil)
-        window?.makeFirstResponder(nil)
         if let doc = jobListingsScrollView.documentView {
             doc.scroll(NSPoint(x: 0, y: 0))
         }
     }
 
+    /// Restores the main job-search experience: cleared query and no listings until the user searches again.
+    private func applyHomeState() {
+        jobKeywordsField.stringValue = ""
+        clearJobSearchResultsUI()
+        window?.makeFirstResponder(nil)
+    }
+
     private func updateSearchBarShadowPath() {
         guard searchBarShadowHost.bounds.width > 0, searchBarShadowHost.bounds.height > 0 else { return }
         let r = searchBarShadowHost.bounds
@@ -589,6 +594,9 @@ final class DashboardView: NSView, NSTextFieldDelegate {
 
     func controlTextDidBeginEditing(_ obj: Notification) {
         applySearchFieldInsertionPoint(obj.object)
+        if (obj.object as? NSTextField) === jobKeywordsField {
+            clearJobSearchResultsUI()
+        }
     }
 
     func controlTextDidChange(_ obj: Notification) {