Skip to content

[#13594] Question incorrectly displayed as saved when there are submission errors#13595

Draft
samuelfangjw wants to merge 5 commits intoTEAMMATES:masterfrom
samuelfangjw:save-state-failure
Draft

[#13594] Question incorrectly displayed as saved when there are submission errors#13595
samuelfangjw wants to merge 5 commits intoTEAMMATES:masterfrom
samuelfangjw:save-state-failure

Conversation

@samuelfangjw
Copy link
Copy Markdown
Member

Fixes #13594

Outline of Solution

Root cause was that hasResponseChangedForRecipients and isSaved is unconditionally set even when there are submission failures.

Solution is to only set these when it has been successfully saved. In addition, hasResponseChanged is changed to be dependent on hasResponseChangedForRecipients. Previously these two variables were set independently leading to inconsistencies.

Comment on lines -527 to -532
this.isSaved = true;
this.hasResponseChanged = false;
this.model.hasResponseChangedForRecipients.forEach(
(_hasResponseChangedForRecipient: boolean, recipientId: string) => {
this.model.hasResponseChangedForRecipients.set(recipientId, false);
});
Copy link
Copy Markdown
Member Author

@samuelfangjw samuelfangjw Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should only be set after saving is completed so they have been removed.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an issue in the feedback session submission UI where a question tab could be shown as “saved” even when submissions fail, by tightening the conditions under which “saved/changed” state is updated.

Changes:

  • Removes isSubmitAllClicked state plumbing and centralizes “changed” tracking on hasResponseChangedForRecipients.
  • Updates save flow to reset “changed” flags only on successful save, and renames getformattedSessionClosingTime to getFormattedSessionClosingTime.
  • Updates unit tests and snapshots to reflect the new state tracking and template bindings.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/web/app/pages-session/session-submission-page/session-submission-page.component.ts Adjusts save flow and “changed” reset logic; renames session closing-time formatter; changes recipient-save error handling.
src/web/app/pages-session/session-submission-page/session-submission-page.component.spec.ts Updates save-flow tests to reflect new hasResponseChangedForRecipients behavior and updated method signature.
src/web/app/pages-session/session-submission-page/session-submission-page.component.html Removes isSubmitAllClicked bindings and updates save handler calls to match the new signature.
src/web/app/pages-session/session-submission-page/snapshots/session-submission-page.component.spec.ts.snap Snapshot updates removing the isSubmitAllClicked input.
src/web/app/components/question-submission-form/question-submission-form.component.ts Replaces mutable hasResponseChanged with a getter; simplifies saved-state calculation; removes isSubmitAllClicked input/output.
src/web/app/components/question-submission-form/question-submission-form.component.spec.ts Updates/extends tests for the new derived hasResponseChanged and revised saved-state behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 402 to +417
triggerRecipientSubmissionFormChange(index: number, field: string, data: any): void {
if (!this.isFormsDisabled) {
this.hasResponseChanged = true;
this.isSubmitAllClickedChange.emit(false);
this.model.hasResponseChangedForRecipients.set(this.model.recipientList[index].recipientIdentifier, true);
if (this.isFormsDisabled) {
return;
}

this.model.recipientSubmissionForms[index] =
{
...this.model.recipientSubmissionForms[index],
[field]: data,
};
const recipientIdentifier: string = this.model.recipientSubmissionForms[index].recipientIdentifier;
this.model.hasResponseChangedForRecipients.set(recipientIdentifier, true);

this.updateIsValidByQuestionConstraint();
this.formModelChange.emit(this.model);
}
this.model.recipientSubmissionForms[index] =
{
...this.model.recipientSubmissionForms[index],
[field]: data,
};

this.updateIsValidByQuestionConstraint();
this.formModelChange.emit(this.model);
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In triggerRecipientSubmissionFormChange, when the changed field is recipientIdentifier (flexible-recipient dropdown), the code currently marks hasResponseChangedForRecipients using the old recipientIdentifier from the model before it gets updated. This can leave a stale key (e.g., '' or a previously selected recipient) stuck at true, causing hasResponseChanged / the saved-state to remain incorrect even after the user picks a different recipient. Consider using the new identifier (data) when field === 'recipientIdentifier' (and potentially clearing the old key) so the change-tracking maps to the currently selected recipient.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Question incorrectly displayed as saved when there are submission errors

2 participants