Skip to content

Commit b9303f8

Browse files
committed
Clearing filter for "Go to questions"
This was necessary for cases where a filter present was hiding the first question, after the button was clicked. I believe it's exceedingly rare that we'd want to preserve their filter when they click this button.
1 parent 38499ac commit b9303f8

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking-questions/checking-questions.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface QuestionChangeActionSource {
4343
export interface QuestionChangedEvent {
4444
questionDoc: QuestionDoc | undefined;
4545
actionSource: QuestionChangeActionSource | undefined;
46+
clearFilter?: boolean;
4647
}
4748

4849
// For performance reasons, this component uses the OnPush change detection strategy rather than the default change
@@ -216,7 +217,7 @@ export class CheckingQuestionsComponent implements OnInit, OnChanges {
216217

217218
protected activateFirstUnansweredQuestion(): void {
218219
if (!this.hasUnansweredQuestion || this._firstUnansweredQuestion == null) return;
219-
this.activateQuestion(this._firstUnansweredQuestion.docs[0], { isQuestionListChange: false });
220+
this.activateQuestion(this._firstUnansweredQuestion.docs[0], { isQuestionListChange: false }, true);
220221
}
221222

222223
private get canAddAnswer(): boolean {
@@ -381,7 +382,7 @@ export class CheckingQuestionsComponent implements OnInit, OnChanges {
381382
this.changeQuestion(-1);
382383
}
383384

384-
activateQuestion(questionDoc: QuestionDoc, actionSource?: QuestionChangeActionSource): void {
385+
activateQuestion(questionDoc: QuestionDoc, actionSource?: QuestionChangeActionSource, clearFilter?: boolean): void {
385386
const verseRef: VerseRefData | undefined = questionDoc.data?.verseRef;
386387

387388
// The reason for the convoluted questionChanged logic is because the change needs to be emitted even if it's the
@@ -397,7 +398,7 @@ export class CheckingQuestionsComponent implements OnInit, OnChanges {
397398
this.storeMostRecentQuestion().then(() => {
398399
// Only emit if not a filter to avoid duplicate emission, as an emit from filter is called elsewhere
399400
if (!actionSource?.isQuestionListChange) {
400-
this.changed.emit({ questionDoc, actionSource });
401+
this.changed.emit({ questionDoc, actionSource, clearFilter });
401402
}
402403

403404
if (questionChanged) {

src/SIL.XForge.Scripture/ClientApp/src/app/checking/checking/checking.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ export class CheckingComponent extends DataLoadingComponent implements OnInit, A
912912
}
913913

914914
// if click question in question list
915-
questionChanged({ questionDoc, actionSource }: QuestionChangedEvent): void {
915+
questionChanged({ questionDoc, actionSource, clearFilter }: QuestionChangedEvent): void {
916916
if (this.questionsList == null) {
917917
return;
918918
}
@@ -922,6 +922,10 @@ export class CheckingComponent extends DataLoadingComponent implements OnInit, A
922922
this.setQuestionsOverlayVisibility(false);
923923
}
924924

925+
if (clearFilter) {
926+
this.resetFilter();
927+
}
928+
925929
if (questionDoc != null) {
926930
this.updateActiveQuestionVerseRef(questionDoc);
927931
this.updateAdjacentQuestions(questionDoc);

0 commit comments

Comments
 (0)