-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dialog, AlertDialog] Fix the nesting of different dialogs (#1167)
- Loading branch information
Showing
6 changed files
with
127 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 3 additions & 16 deletions
19
packages/react/src/alert-dialog/root/AlertDialogRootContext.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use client'; | ||
import * as React from 'react'; | ||
import type { useDialogRoot } from '../root/useDialogRoot'; | ||
|
||
/** | ||
* Common context for dialog & dialog alert components. | ||
*/ | ||
export interface DialogContext extends useDialogRoot.ReturnValue { | ||
/** | ||
* Determines if the dialog is nested within a parent dialog. | ||
*/ | ||
nested: boolean; | ||
} | ||
|
||
export const DialogContext = React.createContext<DialogContext | undefined>(undefined); | ||
|
||
if (process.env.NODE_ENV !== 'production') { | ||
DialogContext.displayName = 'DialogContext'; | ||
} | ||
|
||
export function useDialogContext() { | ||
return React.useContext(DialogContext); | ||
} |