chore: correctly close modals and show toast after creating note from shared text

This commit is contained in:
Aman Harwara
2023-07-13 02:16:54 +05:30
parent 8294d0663f
commit 512b8d9fbc
7 changed files with 50 additions and 9 deletions

View File

@@ -1,7 +1,9 @@
import { getPlatformString } from '@/Utils'
import { classNames } from '@standardnotes/utils'
import { Dialog, useDialogStore } from '@ariakit/react'
import { ForwardedRef, forwardRef, ReactNode } from 'react'
import { ForwardedRef, forwardRef, ReactNode, useCallback } from 'react'
import { mergeRefs } from '@/Hooks/mergeRefs'
import { DialogWithClose } from '@/Utils/CloseOpenModalsAndPopovers'
type Props = {
children: ReactNode
@@ -13,11 +15,20 @@ const HistoryModalDialog = forwardRef(({ children, onDismiss }: Props, ref: Forw
open: true,
})
const addCloseMethod = useCallback(
(element: HTMLDivElement | null) => {
if (element) {
;(element as DialogWithClose).close = onDismiss
}
},
[onDismiss],
)
return (
<Dialog
store={dialog}
aria-label="Note revision history"
ref={ref}
ref={mergeRefs([addCloseMethod, ref])}
className="fixed left-0 top-0 z-modal h-full w-full"
>
<div