Skip to content

Commit

Permalink
fix(feedback): Call dialog.close() in dialog close callbacks in _load…
Browse files Browse the repository at this point in the history
…AndRenderDialog (#13203)

This PR updates `_loadAndRenderDialog` to call `dialog.close()` in the `onFormClose` and `onFormSubmitted` callbacks.
  • Loading branch information
spalmurray-codecov authored Aug 2, 2024
2 parents 4ddc7eb + 7be412c commit d996c22
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 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 @@ -233,10 +245,6 @@ export const buildFeedbackIntegration = ({
if (!dialog) {
dialog = await _loadAndRenderDialog({
...mergedOptions,
onFormClose: () => {
dialog && dialog.close();
mergedOptions.onFormClose && mergedOptions.onFormClose();
},
onFormSubmitted: () => {
dialog && dialog.removeFromDom();
mergedOptions.onFormSubmitted && mergedOptions.onFormSubmitted();
Expand Down

0 comments on commit d996c22

Please sign in to comment.