Fix Android crash by try/catch dialog open (#9335)

This commit is contained in:
Samuel Newman
2025-11-06 17:58:14 +02:00
committed by GitHub
parent 215f97bad9
commit ec2c580aae
+21 -2
View File
@@ -13,6 +13,7 @@ import {
type DialogControlRefProps, type DialogControlRefProps,
type DialogOuterProps, type DialogOuterProps,
} from '#/components/Dialog/types' } from '#/components/Dialog/types'
import {IS_DEV} from '#/env'
import {BottomSheetSnapPoint} from '../../../modules/bottom-sheet/src/BottomSheet.types' import {BottomSheetSnapPoint} from '../../../modules/bottom-sheet/src/BottomSheet.types'
export const Context = createContext<DialogContextProps>({ export const Context = createContext<DialogContextProps>({
@@ -50,10 +51,28 @@ export function useDialogControl(): DialogOuterProps['control'] {
id, id,
ref: control, ref: control,
open: () => { open: () => {
control.current.open() if (control.current) {
control.current.open()
} else {
if (IS_DEV) {
console.warn(
'Attemped to open a dialog control that was not attached to a dialog!\n' +
'Please ensure that the Dialog is mounted when calling open/close',
)
}
}
}, },
close: cb => { close: cb => {
control.current.close(cb) if (control.current) {
control.current.close(cb)
} else {
if (IS_DEV) {
console.warn(
'Attemped to close a dialog control that was not attached to a dialog!\n' +
'Please ensure that the Dialog is mounted when calling open/close',
)
}
}
}, },
}), }),
[id, control], [id, control],