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 89732edf42c3570289067db940b8eba38011d5ca..27ffc567cc4a22dbc3c7aaf25139db25a9e43289 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 @@ -11,6 +11,7 @@ import { RemoveSaveForLater, RemoveCourse, } from '@app/degree-planner/store/actions/course.actions'; +import { CloseCourseSearch } from '@app/degree-planner/store/actions/ui.actions'; import { GlobalState } from '@app/core/state'; import { Course } from '@app/core/models/course'; import * as selectors from '@app/degree-planner/store/selectors'; @@ -180,6 +181,7 @@ export class CourseItemComponent implements OnInit { case 'search': { this.addToTerm(toTermCode); + this.store.dispatch(new CloseCourseSearch()); break; } } @@ -211,13 +213,20 @@ export class CourseItemComponent implements OnInit { ); // If course is in a term, we need to remove it - if (this.type === 'course') { - this.store.dispatch( - new RemoveCourse({ - fromTermCode: new TermCode(termCode), - recordId: this.course.id as number, - }), - ); + // If this course came from search, close the search + switch (this.type) { + case 'course': + this.store.dispatch( + new RemoveCourse({ + fromTermCode: new TermCode(termCode), + recordId: this.course.id as number, + }), + ); + break; + + case 'search': + 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 4fb3b708ce9156008ccbc42bc84e65beae2672f9..6b41307bb05bf67bb54e795260774117b0f3d6f3 100644 --- a/src/app/degree-planner/term-container/term-container.component.ts +++ b/src/app/degree-planner/term-container/term-container.component.ts @@ -12,6 +12,7 @@ import { // Models import * as actions from '@app/degree-planner/store/actions/course.actions'; +import { CloseCourseSearch } from '@app/degree-planner/store/actions/ui.actions'; import * as selectors from '@app/degree-planner/store/selectors'; import { PlannedTerm, PlannedTermNote } from '@app/core/models/planned-term'; import { Note } from '@app/core/models/note'; @@ -257,6 +258,8 @@ export class TermContainerComponent implements OnInit, OnDestroy { newIndex, }), ); + + this.store.dispatch(new CloseCourseSearch()); } }