Cancelling question edits outputs TypeError
On the Monitoring Setup screen: When adding and then editing a question, upon canceling the console outputs a Type Error:
TypeError: result is undefined
Expected Behaivior
There should be no error (instead a toast should indicate the cancellation)
How to reproduce
- Goto Monitoring setup
- Add a Question
- Click on the edit icon on the top right of the question card
- Click on the X icon to close the Modal
Ideas
I think this happens in RccMonitoringSetupPageComponent.editQuestion
:
public async editQuestion(question : Question, questionList: QuestionList): Promise<void> {
const result: QuestionFormData = await this.rccModalController.present(EditQuestionModalComponent, { question, listType: questionList.id })
const language: string = this.translationService.activeLanguage
question.meaning = result.questionTitle
question.translations = {
[language]: result.questionTitle
}
}
.present
returns no value, hence the error.
Clicking the X in EditQuestionModalComponent should throw a UserCanceledError
(from @rcc/core) (can be caught if needed). If it is not caught, the RccErrorHandler
(from @rcc/common) will catch it for you and spawn a toast.