diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 06de6890bc..98ad1709c4 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -124,9 +124,9 @@ export const Button = React.forwardRef( ) => { // This will pick the correct default pressable to use. If we are inside a dialog, we need to use the RNGH // pressable so that it is usable inside the dialog. - const dialogContext = useDialogContext() + const {insideDialog} = useDialogContext() if (!Component) { - if (dialogContext) { + if (insideDialog) { Component = NormalizedRNGHPressable } else { Component = Pressable diff --git a/src/components/Dialog/context.ts b/src/components/Dialog/context.ts index 859f8edd77..27b8a56375 100644 --- a/src/components/Dialog/context.ts +++ b/src/components/Dialog/context.ts @@ -9,6 +9,7 @@ import { export const Context = React.createContext({ close: () => {}, + insideDialog: false, }) export function useDialogContext() { diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 303da0d009..6fbc8d87a0 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -82,7 +82,7 @@ export function Outer({ [open, close], ) - const context = React.useMemo(() => ({close}), [close]) + const context = React.useMemo(() => ({close, insideDialog: true}), [close]) return ( diff --git a/src/components/Dialog/types.ts b/src/components/Dialog/types.ts index ed83bd02b1..a8568e5748 100644 --- a/src/components/Dialog/types.ts +++ b/src/components/Dialog/types.ts @@ -37,6 +37,7 @@ export type DialogControlProps = DialogControlRefProps & { export type DialogContextProps = { close: DialogControlProps['close'] + insideDialog: boolean } export type DialogControlOpenOptions = {