Selaa lähdekoodia

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 3 viikkoa sitten
vanhempi
commit
00f77a6e74
1 muutettua tiedostoa jossa 12 lisäystä ja 4 poistoa
  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 {
543
         }
543
         }
544
     }
544
     }
545
 
545
 
546
-    /// Restores the main job-search experience: cleared query and no listings until the user searches again.
547
-    private func applyHomeState() {
548
-        jobKeywordsField.stringValue = ""
546
+    /// Removes result cards or the “no matches” message so a new search starts from a blank listing area.
547
+    private func clearJobSearchResultsUI() {
549
         configureJobListings([], noResultsForQuery: nil)
548
         configureJobListings([], noResultsForQuery: nil)
550
-        window?.makeFirstResponder(nil)
551
         if let doc = jobListingsScrollView.documentView {
549
         if let doc = jobListingsScrollView.documentView {
552
             doc.scroll(NSPoint(x: 0, y: 0))
550
             doc.scroll(NSPoint(x: 0, y: 0))
553
         }
551
         }
554
     }
552
     }
555
 
553
 
554
+    /// Restores the main job-search experience: cleared query and no listings until the user searches again.
555
+    private func applyHomeState() {
556
+        jobKeywordsField.stringValue = ""
557
+        clearJobSearchResultsUI()
558
+        window?.makeFirstResponder(nil)
559
+    }
560
+
556
     private func updateSearchBarShadowPath() {
561
     private func updateSearchBarShadowPath() {
557
         guard searchBarShadowHost.bounds.width > 0, searchBarShadowHost.bounds.height > 0 else { return }
562
         guard searchBarShadowHost.bounds.width > 0, searchBarShadowHost.bounds.height > 0 else { return }
558
         let r = searchBarShadowHost.bounds
563
         let r = searchBarShadowHost.bounds
@@ -589,6 +594,9 @@ final class DashboardView: NSView, NSTextFieldDelegate {
589
 
594
 
590
     func controlTextDidBeginEditing(_ obj: Notification) {
595
     func controlTextDidBeginEditing(_ obj: Notification) {
591
         applySearchFieldInsertionPoint(obj.object)
596
         applySearchFieldInsertionPoint(obj.object)
597
+        if (obj.object as? NSTextField) === jobKeywordsField {
598
+            clearJobSearchResultsUI()
599
+        }
592
     }
600
     }
593
 
601
 
594
     func controlTextDidChange(_ obj: Notification) {
602
     func controlTextDidChange(_ obj: Notification) {