fix: admin: a dialog just after a toast was made invisible
Massimo Melina committed
May 3, 2023 at 12:15 UTC
0f41ee281437554155b23dd136d5fcb3d0670d1d
1 file changed
+4
-3
shared/dialogs.ts
+4
-3
@@ -16,6 +16,7 @@ export interface DialogOptions {
16
padding?: boolean
17
position?: [number, number]
18
dialogProps?: Record<string, any>
19
+ $id?: number
20
21
Container?: FunctionComponent<DialogOptions>
22
}
@@ -31,8 +32,8 @@ export const dialogsDefaults: Partial<DialogOptions> = {
32
export function Dialogs() {
33
const snap = useSnapshot(dialogs)
34
return h(Fragment, {},
34
- snap.length > 0 && snap.map((d,i) =>
35
- h(Dialog, { key:i, ...(d as DialogOptions) })))
35
+ snap.length > 0 && snap.map(d =>
36
+ h(Dialog, { key: d.$id, ...(d as DialogOptions) })))
37
}
38
39
function Dialog(d:DialogOptions) {
@@ -98,7 +99,7 @@ function onKeyDown(ev:any) {
99
100
export function newDialog(options: DialogOptions) {
101
const $id = Math.random()
101
- ;(options as any).$id = $id // object identity is not working because of the proxy. This is a possible workaround
102
+ options.$id = $id // object identity is not working because of the proxy. This is a possible workaround
103
dialogs.push(options)
104
return (v?:any) => {
105
const i = dialogs.findIndex(x => (x as any).$id === $id)