Skip to content

Commit

Permalink
Move dialog.close() call into _loadAndRenderDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
spalmurray-codecov committed Aug 2, 2024
1 parent f9a040a commit 841d57c
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions packages/feedback/src/core/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,24 @@ export const buildFeedbackIntegration = ({
logger.error('[Feedback] Missing feedback screenshot integration. Proceeding without screenshots.');
}

return modalIntegration.createDialog({
options,
const dialog = modalIntegration.createDialog({
options: {
...options,
onFormClose: () => {
dialog && dialog.close();
options.onFormClose && options.onFormClose();
},
onFormSubmitted: () => {
dialog && dialog.close();
options.onFormSubmitted && options.onFormSubmitted();
},
},
screenshotIntegration: screenshotRequired ? screenshotIntegration : undefined,
sendFeedback,
shadow: _createShadow(options),
});

return dialog;
};

const _attachTo = (el: Element | string, optionOverrides: OverrideFeedbackConfiguration = {}): Unsubscribe => {
Expand All @@ -234,7 +246,7 @@ export const buildFeedbackIntegration = ({
dialog = await _loadAndRenderDialog({
...mergedOptions,
onFormClose: () => {
dialog && dialog.close();
dialog && dialog.removeFromDom();
mergedOptions.onFormClose && mergedOptions.onFormClose();
},
onFormSubmitted: () => {
Expand Down Expand Up @@ -318,21 +330,7 @@ export const buildFeedbackIntegration = ({
async createForm(
optionOverrides: OverrideFeedbackConfiguration = {},
): Promise<ReturnType<FeedbackModalIntegration['createDialog']>> {
const mergedOptions = mergeOptions(_options, optionOverrides);

const dialog = await _loadAndRenderDialog({
...mergedOptions,
onFormClose: () => {
dialog && dialog.close();
mergedOptions.onFormClose && mergedOptions.onFormClose();
},
onFormSubmitted: () => {
dialog && dialog.close();
mergedOptions.onFormSubmitted && mergedOptions.onFormSubmitted();
},
});

return dialog;
return _loadAndRenderDialog(mergeOptions(_options, optionOverrides));
},

/**
Expand Down

0 comments on commit 841d57c

Please sign in to comment.