From 0d774f402e01add00d7a4759dd9f6b106d26147b Mon Sep 17 00:00:00 2001
From: Scott Berg <saberg3@wisc.edu>
Date: Thu, 18 Apr 2019 15:52:35 -0500
Subject: [PATCH] Update search to only close after add on mobile

---
 src/app/degree-planner/degree-planner.component.html   |  2 +-
 .../shared/course-item/course-item.component.ts        | 10 +++++++---
 .../term-container/term-container.component.ts         |  4 +++-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/app/degree-planner/degree-planner.component.html b/src/app/degree-planner/degree-planner.component.html
index 25a25e1..eb619c9 100644
--- a/src/app/degree-planner/degree-planner.component.html
+++ b/src/app/degree-planner/degree-planner.component.html
@@ -1,4 +1,4 @@
-<mat-sidenav-container hasBackdrop="false">
+<mat-sidenav-container [hasBackdrop]="mobileView.matches">
   <mat-sidenav
     #addMenu
     position="end"
diff --git a/src/app/degree-planner/shared/course-item/course-item.component.ts b/src/app/degree-planner/shared/course-item/course-item.component.ts
index 27ffc56..ad2abad 100644
--- a/src/app/degree-planner/shared/course-item/course-item.component.ts
+++ b/src/app/degree-planner/shared/course-item/course-item.component.ts
@@ -181,7 +181,9 @@ export class CourseItemComponent implements OnInit {
 
       case 'search': {
         this.addToTerm(toTermCode);
-        this.store.dispatch(new CloseCourseSearch());
+        if (this.mobileView.matches) {
+          this.store.dispatch(new CloseCourseSearch());
+        }
         break;
       }
     }
@@ -213,7 +215,7 @@ export class CourseItemComponent implements OnInit {
     );
 
     // If course is in a term, we need to remove it
-    // If this course came from search, close the search
+    // If this course came from search and is mobile, close the search
     switch (this.type) {
       case 'course':
         this.store.dispatch(
@@ -225,7 +227,9 @@ export class CourseItemComponent implements OnInit {
         break;
 
       case 'search':
-        this.store.dispatch(new CloseCourseSearch());
+        if (this.mobileView.matches) {
+          this.store.dispatch(new CloseCourseSearch());
+        }
         break;
     }
   }
diff --git a/src/app/degree-planner/term-container/term-container.component.ts b/src/app/degree-planner/term-container/term-container.component.ts
index 6b41307..269b250 100644
--- a/src/app/degree-planner/term-container/term-container.component.ts
+++ b/src/app/degree-planner/term-container/term-container.component.ts
@@ -259,7 +259,9 @@ export class TermContainerComponent implements OnInit, OnDestroy {
         }),
       );
 
-      this.store.dispatch(new CloseCourseSearch());
+      if (this.mobileView.matches) {
+        this.store.dispatch(new CloseCourseSearch());
+      }
     }
   }
 
-- 
GitLab