@@ -11,6 +11,9 @@ export default class DialogPage extends React.Component {
11
11
super ( ) ;
12
12
this . state = {
13
13
modal : false ,
14
+ showDialogStandardActions : false ,
15
+ showDialogCustomActions : false ,
16
+ showDialogScrollable : false ,
14
17
} ;
15
18
this . _handleCustomDialogCancel = this . _handleCustomDialogCancel . bind ( this ) ;
16
19
this . _handleCustomDialogSubmit = this . _handleCustomDialogSubmit . bind ( this ) ;
@@ -19,6 +22,7 @@ export default class DialogPage extends React.Component {
19
22
this . _handleCustomDialogTouchTap = this . _handleCustomDialogTouchTap . bind ( this ) ;
20
23
this . _handleStandardDialogTouchTap = this . _handleStandardDialogTouchTap . bind ( this ) ;
21
24
this . _handleScrollableDialogTouchTap = this . _handleScrollableDialogTouchTap . bind ( this ) ;
25
+ this . _handleRequestClose = this . _handleRequestClose . bind ( this ) ;
22
26
this . _handleToggleChange = this . _handleToggleChange . bind ( this ) ;
23
27
}
24
28
@@ -69,8 +73,20 @@ export default class DialogPage extends React.Component {
69
73
name : 'openImmediately' ,
70
74
type : 'bool' ,
71
75
header : 'default: false' ,
76
+ desc : 'Deprecated: Set to true to have the dialog automatically open on mount.' ,
77
+ } ,
78
+ {
79
+ name : 'defaultIsOpen' ,
80
+ type : 'bool' ,
81
+ header : 'default: false' ,
72
82
desc : 'Set to true to have the dialog automatically open on mount.' ,
73
83
} ,
84
+ {
85
+ name : 'isOpen' ,
86
+ type : 'bool' ,
87
+ header : 'default: null' ,
88
+ desc : 'Controls whether the Dialog is opened or not.' ,
89
+ } ,
74
90
{
75
91
name : 'title' ,
76
92
type : 'node' ,
@@ -95,16 +111,6 @@ export default class DialogPage extends React.Component {
95
111
{
96
112
name : 'Methods' ,
97
113
infoArray : [
98
- {
99
- name : 'dismiss' ,
100
- header : 'Dialog.dismiss()' ,
101
- desc : 'Hides the dialog.' ,
102
- } ,
103
- {
104
- name : 'show' ,
105
- header : 'Dialog.show()' ,
106
- desc : 'Shows the dialog.' ,
107
- } ,
108
114
{
109
115
name : 'isOpen' ,
110
116
header : 'Dialog.isOpen()' ,
@@ -116,14 +122,9 @@ export default class DialogPage extends React.Component {
116
122
name : 'Events' ,
117
123
infoArray : [
118
124
{
119
- name : 'onDismiss' ,
120
- header : 'function()' ,
121
- desc : 'Fired when the dialog is dismissed.' ,
122
- } ,
123
- {
124
- name : 'onShow' ,
125
- header : 'function()' ,
126
- desc : 'Fired when the dialog is shown.' ,
125
+ name : 'onRequestClose' ,
126
+ header : 'function(buttonClicked)' ,
127
+ desc : 'Fired when the dialog is requested to be closed by a click outside the dialog or on the buttons.' ,
127
128
} ,
128
129
] ,
129
130
} ,
@@ -175,15 +176,17 @@ export default class DialogPage extends React.Component {
175
176
title = "Dialog With Standard Actions"
176
177
actions = { standardActions }
177
178
actionFocus = "submit"
178
- modal = { this . state . modal } >
179
+ isOpen = { this . state . showDialogStandardActions }
180
+ onRequestClose = { this . _handleRequestClose } >
179
181
The actions in this window are created from the json that's passed in.
180
182
</ Dialog >
181
183
182
184
< Dialog
183
185
ref = "customDialog"
184
186
title = "Dialog With Custom Actions"
185
187
actions = { customActions }
186
- modal = { this . state . modal } >
188
+ isOpen = { this . state . showDialogCustomActions }
189
+ onRequestClose = { this . _handleRequestClose } >
187
190
The actions in this window were passed in as an array of react objects.
188
191
</ Dialog >
189
192
< div style = { { width : '300px' , margin : '0 auto' , paddingTop : '20px' } } >
@@ -196,9 +199,10 @@ export default class DialogPage extends React.Component {
196
199
ref = "scrollableContentDialog"
197
200
title = "Dialog With Scrollable Content"
198
201
actions = { scrollableCustomActions }
199
- modal = { this . state . modal }
200
202
autoDetectWindowHeight = { true }
201
- autoScrollBodyContent = { true } >
203
+ autoScrollBodyContent = { true }
204
+ isOpen = { this . state . showDialogScrollable }
205
+ onRequestClose = { this . _handleRequestClose } >
202
206
< div style = { { height : '1000px' } } >
203
207
Really long content
204
208
</ div >
@@ -214,35 +218,58 @@ export default class DialogPage extends React.Component {
214
218
}
215
219
216
220
_handleCustomDialogCancel ( ) {
217
- this . refs . customDialog . dismiss ( ) ;
221
+ this . setState ( {
222
+ showDialogCustomActions : true ,
223
+ } ) ;
218
224
}
219
225
220
226
_handleCustomDialogSubmit ( ) {
221
- this . refs . customDialog . dismiss ( ) ;
227
+ this . setState ( {
228
+ showDialogCustomActions : true ,
229
+ } ) ;
222
230
}
223
231
224
232
_handleToggleChange ( e , toggled ) {
225
233
this . setState ( { modal : toggled } ) ;
226
234
}
227
235
228
236
_handleScrollableDialogCancel ( ) {
229
- this . refs . scrollableContentDialog . dismiss ( ) ;
237
+ this . setState ( {
238
+ showDialogScrollable : false ,
239
+ } ) ;
230
240
}
231
241
232
242
_handleScrollableDialogSubmit ( ) {
233
- this . refs . scrollableContentDialog . dismiss ( ) ;
243
+ this . setState ( {
244
+ showDialogScrollable : false ,
245
+ } ) ;
234
246
}
235
247
236
248
_handleCustomDialogTouchTap ( ) {
237
- this . refs . customDialog . show ( ) ;
249
+ this . setState ( {
250
+ showDialogScrollable : true ,
251
+ } ) ;
238
252
}
239
253
240
254
_handleStandardDialogTouchTap ( ) {
241
- this . refs . standardDialog . show ( ) ;
255
+ this . setState ( {
256
+ showDialogStandardActions : true ,
257
+ } ) ;
242
258
}
243
259
244
260
_handleScrollableDialogTouchTap ( ) {
245
- this . refs . scrollableContentDialog . show ( ) ;
261
+ this . setState ( {
262
+ showDialogScrollable : true ,
263
+ } ) ;
264
+ }
265
+
266
+ _handleRequestClose ( buttonClicked ) {
267
+ if ( ! buttonClicked && this . state . modal ) return ;
268
+ this . setState ( {
269
+ showDialogStandardActions : false ,
270
+ showDialogCustomActions : false ,
271
+ showDialogScrollable : false ,
272
+ } ) ;
246
273
}
247
274
248
275
}
0 commit comments