@@ -11,6 +11,7 @@ import { Heading } from '../src/Heading';
1111import { IconButton } from '../src/IconButton' ;
1212import { Modal , ModalOverlay } from '../src/Modal' ;
1313import { Text } from '../src/Text' ;
14+ import { ToastRegion , toastQueue } from '../src/Toast' ;
1415
1516const meta : Meta < typeof Modal > = {
1617 component : Modal ,
@@ -110,3 +111,73 @@ export const Drawer: Story = {
110111 } ,
111112 } ,
112113} ;
114+
115+ /**
116+ * Bug reproduction: Dialog closes when clicking a button inside it while Toast is active.
117+ *
118+ * Steps to reproduce:
119+ * 1. Click "Show Toast" to display a toast notification
120+ * 2. Click "Open Dialog" to open the modal
121+ * 3. Click "Click Me" button inside the dialog
122+ *
123+ * Expected: Button click should work normally, dialog stays open
124+ * Actual: Dialog closes unexpectedly
125+ */
126+ export const DialogWithActiveToast : Story = {
127+ render : ( args ) => {
128+ return (
129+ < >
130+ < ToastRegion />
131+ < div style = { { display : 'flex' , gap : '1rem' , marginBottom : '1rem' } } >
132+ < DialogTrigger >
133+ < Button variant = "primary" > Open Dialog</ Button >
134+ < ModalOverlay >
135+ < Modal { ...args } >
136+ < Dialog >
137+ { ( { close } ) => (
138+ < >
139+ < div slot = "header" >
140+ < Heading slot = "title" > Dialog with Toast Active</ Heading >
141+ < IconButton
142+ aria-label = "close"
143+ icon = "cancel"
144+ size = "small"
145+ variant = "minimal"
146+ onPress = { close }
147+ />
148+ < Text slot = "subtitle" > Try clicking the button below with toast active</ Text >
149+ </ div >
150+ < div slot = "body" >
151+ < p >
152+ When a toast is visible, clicking the button below should NOT close the
153+ dialog.
154+ </ p >
155+ < div style = { { marginTop : '1rem' } } >
156+ < Button
157+ onPress = { ( ) => {
158+ toastQueue . add ( {
159+ title : 'Toast is active' ,
160+ description : 'Now try clicking the button inside the dialog' ,
161+ status : 'info' ,
162+ } ) ;
163+ } }
164+ >
165+ Show Toast
166+ </ Button > { ' ' }
167+ </ div >
168+ </ div >
169+ < div slot = "footer" >
170+ < Button slot = "close" > Cancel</ Button >
171+ < Button variant = "primary" > Confirm</ Button >
172+ </ div >
173+ </ >
174+ ) }
175+ </ Dialog >
176+ </ Modal >
177+ </ ModalOverlay >
178+ </ DialogTrigger >
179+ </ div >
180+ </ >
181+ ) ;
182+ } ,
183+ } ;
0 commit comments