Procházet 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 před 3 týdny
rodič
revize
00f77a6e74
1 změnil soubory, kde provedl 12 přidání a 4 odebrání
  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 548
         configureJobListings([], noResultsForQuery: nil)
550
-        window?.makeFirstResponder(nil)
551 549
         if let doc = jobListingsScrollView.documentView {
552 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 561
     private func updateSearchBarShadowPath() {
557 562
         guard searchBarShadowHost.bounds.width > 0, searchBarShadowHost.bounds.height > 0 else { return }
558 563
         let r = searchBarShadowHost.bounds
@@ -589,6 +594,9 @@ final class DashboardView: NSView, NSTextFieldDelegate {
589 594
 
590 595
     func controlTextDidBeginEditing(_ obj: Notification) {
591 596
         applySearchFieldInsertionPoint(obj.object)
597
+        if (obj.object as? NSTextField) === jobKeywordsField {
598
+            clearJobSearchResultsUI()
599
+        }
592 600
     }
593 601
 
594 602
     func controlTextDidChange(_ obj: Notification) {