Skip to content

fix(browser-sdk): call onAfterSubmit once when scored feedback closes - #798

Open
roncohen wants to merge 4 commits into
mainfrom
fix/feedback-after-submit-on-close
Open

roncohen wants to merge 4 commits into
mainfrom
fix/feedback-after-submit-on-close

Conversation

@roncohen

@roncohen roncohen commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Call onAfterSubmit once per feedback form: after Send, or on close with a saved score. Applies to both automated surveys and requestFeedback().

  • Close-only callbacks contain the latest saved score and an empty comment, never draft text.
  • Wait for pending saves; do not notify again after Send or when closing without feedback.
  • Include native modal Escape and replacement by another form in the close lifecycle.

Kept four focused browser regressions per feedback source: score-only close, Send followed by auto-close, close during Send, and replacement during a score save. Removed the overlapping unit/browser matrix and the unrelated test-harness refactor. HTTP-failure handling is split into #799, based separately on main.

Verification

  • Browser SDK unit tests: 208 passed.
  • Browser tests: 72 passed across Chromium, Firefox, and WebKit, including 24 runs of the new regression cases.
  • Browser/native source typechecks and build: passed.
  • Lint, formatting, and diff checks: passed.

The declaration plugin still reports the previously verified baseline MSW HttpResponse test-type diagnostics; no new diagnostics were introduced.

Copilot AI balanced review requested due to automatic review settings November 6, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Replacing an open feedback form can skip its wrapped onClose and leave an unsent saved score without onAfterSubmit, requiring lifecycle finalization and a regression test.

1 open issue
What changed in this PR

This PR centralizes the browser SDK’s feedback callback lifecycle so manual and automated forms report saved scores when users close without pressing Send.

Changes:

  • Adds once-per-form notification handling, including pending saves and out-of-order score responses.
  • Routes modal Escape cancellation through existing dismissal callbacks.
  • Adds lifecycle regression tests, API documentation, and a patch changeset.
File Description
packages/​browser-sdk/​test/​feedbackSubmissionCallback.test.ts Tests notification timing, failures, and duplicate prevention.
packages/​browser-sdk/​test/​e2e/​feedback-widget.browser.spec.ts Covers manual and automated submission and dismissal flows.
packages/​browser-sdk/​src/​ui/​Dialog.tsx Handles native modal Escape cancellation.
packages/​browser-sdk/​src/​feedback/​ui/​withFeedbackSubmissionCallback.ts Implements the shared callback lifecycle.
packages/​browser-sdk/​src/​feedback/​ui/​types.ts Defines and documents the shared callback option.
packages/​browser-sdk/​src/​feedback/​ui/​index.ts Applies the lifecycle wrapper when opening forms.
packages/​browser-sdk/​src/​feedback/​feedback.ts Removes automated feedback’s separate callback invocation.
packages/​browser-sdk/​src/​client.ts Passes manual feedback callbacks to the shared UI lifecycle.
.changeset/​friendly-feedback-close.md Documents the browser SDK patch.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 6, 2026 14:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the feedback callback lifecycle changes.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 6, 2026 16:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block approval of the feedback callback lifecycle changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 7, 2026 08:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the unified feedback callback lifecycle.

No open issues 🎉

Review effort: Balanced

@roncohen
roncohen added this pull request to the merge queue Nov 7, 2026
@roncohen
roncohen removed this pull request from the merge queue due to a manual request Nov 7, 2026
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.

2 participants