Skip to content

fix(app-admin): call onClose callback when dialog is closed #4694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions packages/app-admin/src/components/Dialogs/DialogsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ export const DialogsProvider = ({ children }: DialogsProviderProps) => {
};

const closeDialog = (id: string) => {
const dialog = dialogs.get(id);

// Call the onClose callback if it exists
if (dialog?.onClose && typeof dialog.onClose === "function") {
try {
dialog.onClose();
} catch (error) {
// Log error but don't prevent dialog cleanup
console.error("Error in dialog onClose callback:", error);
}
}

setDialogs(dialogs => {
const newDialogs = new Map(dialogs);
newDialogs.delete(id);
Expand Down
Loading