Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/migration/feedback.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ For example, `attachTo()` is a convenience wrapper over the lifecycle methods. Y
function attachTo(button: HTMLElement) {
const handleClick = () => {
const widget = feedbackInstance.createWidget({
onFormClose: () => {
onFormClose: ({ reason }) => {
widget.close();
},
onFormSubmited: () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/feedback/src/core/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ export const buildFeedbackIntegration = ({
if (!dialog) {
dialog = await _loadAndRenderDialog({
...mergedOptions,
onFormClose: () => {
onFormClose: ({ reason }) => {
dialog && dialog.close();
mergedOptions.onFormClose && mergedOptions.onFormClose();
mergedOptions.onFormClose && mergedOptions.onFormClose({ reason });
},
onFormSubmitted: () => {
dialog && dialog.removeFromDom();
Expand Down
6 changes: 5 additions & 1 deletion packages/feedback/src/modal/components/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export function Dialog({ open, onFormSubmitted, ...props }: Props): VNode {
</div>
</div>
) : (
<dialog class="dialog" onClick={options.onFormClose} open={open}>
<dialog
class="dialog"
onClick={() => options.onFormClose && options.onFormClose({ reason: 'dialog-dismissed' })}
open={open}
>
<div class="dialog__position">
<div
class="dialog__content"
Expand Down
4 changes: 2 additions & 2 deletions packages/feedback/src/modal/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface Props extends Pick<FeedbackInternalOptions, 'showEmail' | 'show
options: FeedbackInternalOptions;
defaultEmail: string;
defaultName: string;
onFormClose: () => void;
onFormClose: (args: { reason: 'dialog-dismissed' | 'form-cancelled' }) => void;
onSubmit: SendFeedback;
onSubmitSuccess: (data: FeedbackFormData) => void;
onSubmitError: (error: Error) => void;
Expand Down Expand Up @@ -217,7 +217,7 @@ export function Form({
<button class="btn btn--primary" type="submit">
{submitButtonLabel}
</button>
<button class="btn btn--default" type="button" onClick={onFormClose}>
<button class="btn btn--default" type="button" onClick={() => onFormClose({ reason: 'form-cancelled' })}>
{cancelButtonLabel}
</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/feedback/src/modal/integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export const feedbackModalIntegration = ((): FeedbackModalIntegration => {
showEmail={options.showEmail || options.isEmailRequired}
defaultName={(userKey && user && user[userKey.name]) || ''}
defaultEmail={(userKey && user && user[userKey.email]) || ''}
onFormClose={() => {
onFormClose={({ reason }) => {
renderContent(false);
options.onFormClose && options.onFormClose();
options.onFormClose && options.onFormClose({ reason });
}}
onSubmit={sendFeedback}
onSubmitSuccess={(data: FeedbackFormData) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/feedback/src/util/mergeOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export function mergeOptions(
optionOverrides.onFormOpen && optionOverrides.onFormOpen();
defaultOptions.onFormOpen && defaultOptions.onFormOpen();
},
onFormClose: () => {
optionOverrides.onFormClose && optionOverrides.onFormClose();
defaultOptions.onFormClose && defaultOptions.onFormClose();
onFormClose: (...args) => {
optionOverrides.onFormClose && optionOverrides.onFormClose(...args);
defaultOptions.onFormClose && defaultOptions.onFormClose(...args);
},
onSubmitSuccess: (data: FeedbackFormData) => {
optionOverrides.onSubmitSuccess && optionOverrides.onSubmitSuccess(data);
Expand Down
2 changes: 1 addition & 1 deletion packages/integration-shims/src/Feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Integration } from '@sentry/types';
import { consoleSandbox } from '@sentry/utils';
import { FAKE_FUNCTION } from './common';

const FEEDBACK_INTEGRATION_METHODS = ['attachTo', 'createWidget', 'remove'] as const;
const FEEDBACK_INTEGRATION_METHODS = ['attachTo', 'createForm', 'createWidget', 'remove'] as const;
Copy link
Member Author

Choose a reason for hiding this comment

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

This shim was missing before, nice to get it in


type FeedbackSpecificMethods = Record<(typeof FEEDBACK_INTEGRATION_METHODS)[number], () => void>;

Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/feedback/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export interface FeedbackCallbacks {
/**
* Callback when form is closed and not submitted
*/
onFormClose?: () => void;
onFormClose?: (args: { reason: 'dialog-dismissed' | 'form-cancelled' }) => void;

/**
* Callback when feedback is successfully submitted
Expand Down