diff --git a/.changeset/sweet-onions-heal.md b/.changeset/sweet-onions-heal.md new file mode 100644 index 00000000000..488b98447d7 --- /dev/null +++ b/.changeset/sweet-onions-heal.md @@ -0,0 +1,5 @@ +--- +'@primer/react': patch +--- + +Fixed confirm() leaving
s in the DOM. diff --git a/src/ConfirmationDialog/ConfirmationDialog.tsx b/src/ConfirmationDialog/ConfirmationDialog.tsx index 0fa9a28dd49..f3aae91413c 100644 --- a/src/ConfirmationDialog/ConfirmationDialog.tsx +++ b/src/ConfirmationDialog/ConfirmationDialog.tsx @@ -150,7 +150,7 @@ export type ConfirmOptions = Omit & {content async function confirm(themeProps: ThemeProviderProps, options: ConfirmOptions): Promise { const {content, ...confirmationDialogProps} = options return new Promise(resolve => { - hostElement = document.createElement('div') + hostElement ||= document.createElement('div') if (!hostElement.isConnected) document.body.append(hostElement) const root = createRoot(hostElement) const onClose: ConfirmationDialogProps['onClose'] = gesture => {