Skip to content

Conversation

@Saby-Bishops
Copy link
Member

@Saby-Bishops Saby-Bishops commented Jan 21, 2026

fixes: #9288

…ed change detection

  • Migrated to NonNullableFormBuilder and typed forms for better type safety.
  • Consolidated valueChanges subscriptions using merge from rxjs.
  • Introduced getCurrentState helper for consistent form state serialization.
  • Enhanced unsaved changes tracking with isFormPristine and getHasUnsavedChanges methods.
  • Updated onSubmit to use getRawValue() ensuring all form data is captured.
  • Cleaned up imports and standardized component structure.

Jules link: https://jules.google.com/session/6506753247234204143/code/src/app/health/health-update.component.ts

…ed change detection

- Migrated to NonNullableFormBuilder and typed forms for better type safety.
- Consolidated valueChanges subscriptions using merge from rxjs.
- Introduced getCurrentState helper for consistent form state serialization.
- Enhanced unsaved changes tracking with isFormPristine and getHasUnsavedChanges methods.
- Updated onSubmit to use getRawValue() ensuring all form data is captured.
- Cleaned up imports and standardized component structure.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7af993301c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +165 to 167
isFormPristine(): boolean {
return this.getCurrentState() === this.initialFormValues;
}

Choose a reason for hiding this comment

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

P2 Badge Guard unsaved check before initial state is captured

When the user navigates away or refreshes before captureInitialState() runs (i.e., before the health data request returns), initialFormValues is still undefined. In that window isFormPristine() compares getCurrentState() to undefined, which is always false, so canDeactivate() / beforeunload will prompt for unsaved changes even if the user never edited anything. This is a regression from the prior behavior where hasUnsavedChanges stayed false until subscriptions ran. Consider initializing initialFormValues earlier or short‑circuiting the check when it’s unset.

Useful? React with 👍 / 👎.

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.

src/app/health/health-update.component.ts

2 participants