Skip to content

Commit

Permalink
don't recreate hostElements each time (#4033)
Browse files Browse the repository at this point in the history
* don't recreate hostElements each time

* changeset
  • Loading branch information
keithamus authored Dec 8, 2023
1 parent 83c125f commit bca709d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sweet-onions-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Fixed confirm() leaving <div>s in the DOM.
2 changes: 1 addition & 1 deletion src/ConfirmationDialog/ConfirmationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export type ConfirmOptions = Omit<ConfirmationDialogProps, 'onClose'> & {content
async function confirm(themeProps: ThemeProviderProps, options: ConfirmOptions): Promise<boolean> {
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 => {
Expand Down

0 comments on commit bca709d

Please sign in to comment.