@@ -11,6 +11,9 @@ export default class DialogPage extends React.Component {
1111 super ( ) ;
1212 this . state = {
1313 modal : false ,
14+ showDialogStandardActions : false ,
15+ showDialogCustomActions : false ,
16+ showDialogScrollable : false ,
1417 } ;
1518 this . _handleCustomDialogCancel = this . _handleCustomDialogCancel . bind ( this ) ;
1619 this . _handleCustomDialogSubmit = this . _handleCustomDialogSubmit . bind ( this ) ;
@@ -19,6 +22,7 @@ export default class DialogPage extends React.Component {
1922 this . _handleCustomDialogTouchTap = this . _handleCustomDialogTouchTap . bind ( this ) ;
2023 this . _handleStandardDialogTouchTap = this . _handleStandardDialogTouchTap . bind ( this ) ;
2124 this . _handleScrollableDialogTouchTap = this . _handleScrollableDialogTouchTap . bind ( this ) ;
25+ this . _handleRequestClose = this . _handleRequestClose . bind ( this ) ;
2226 this . _handleToggleChange = this . _handleToggleChange . bind ( this ) ;
2327 }
2428
@@ -69,8 +73,20 @@ export default class DialogPage extends React.Component {
6973 name : 'openImmediately' ,
7074 type : 'bool' ,
7175 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' ,
7282 desc : 'Set to true to have the dialog automatically open on mount.' ,
7383 } ,
84+ {
85+ name : 'isOpen' ,
86+ type : 'bool' ,
87+ header : 'default: null' ,
88+ desc : 'Controls whether the Dialog is opened or not.' ,
89+ } ,
7490 {
7591 name : 'title' ,
7692 type : 'node' ,
@@ -95,16 +111,6 @@ export default class DialogPage extends React.Component {
95111 {
96112 name : 'Methods' ,
97113 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- } ,
108114 {
109115 name : 'isOpen' ,
110116 header : 'Dialog.isOpen()' ,
@@ -116,14 +122,9 @@ export default class DialogPage extends React.Component {
116122 name : 'Events' ,
117123 infoArray : [
118124 {
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.' ,
127128 } ,
128129 ] ,
129130 } ,
@@ -175,15 +176,17 @@ export default class DialogPage extends React.Component {
175176 title = "Dialog With Standard Actions"
176177 actions = { standardActions }
177178 actionFocus = "submit"
178- modal = { this . state . modal } >
179+ isOpen = { this . state . showDialogStandardActions }
180+ onRequestClose = { this . _handleRequestClose } >
179181 The actions in this window are created from the json that's passed in.
180182 </ Dialog >
181183
182184 < Dialog
183185 ref = "customDialog"
184186 title = "Dialog With Custom Actions"
185187 actions = { customActions }
186- modal = { this . state . modal } >
188+ isOpen = { this . state . showDialogCustomActions }
189+ onRequestClose = { this . _handleRequestClose } >
187190 The actions in this window were passed in as an array of react objects.
188191 </ Dialog >
189192 < div style = { { width : '300px' , margin : '0 auto' , paddingTop : '20px' } } >
@@ -196,9 +199,10 @@ export default class DialogPage extends React.Component {
196199 ref = "scrollableContentDialog"
197200 title = "Dialog With Scrollable Content"
198201 actions = { scrollableCustomActions }
199- modal = { this . state . modal }
200202 autoDetectWindowHeight = { true }
201- autoScrollBodyContent = { true } >
203+ autoScrollBodyContent = { true }
204+ isOpen = { this . state . showDialogScrollable }
205+ onRequestClose = { this . _handleRequestClose } >
202206 < div style = { { height : '1000px' } } >
203207 Really long content
204208 </ div >
@@ -214,35 +218,58 @@ export default class DialogPage extends React.Component {
214218 }
215219
216220 _handleCustomDialogCancel ( ) {
217- this . refs . customDialog . dismiss ( ) ;
221+ this . setState ( {
222+ showDialogCustomActions : true ,
223+ } ) ;
218224 }
219225
220226 _handleCustomDialogSubmit ( ) {
221- this . refs . customDialog . dismiss ( ) ;
227+ this . setState ( {
228+ showDialogCustomActions : true ,
229+ } ) ;
222230 }
223231
224232 _handleToggleChange ( e , toggled ) {
225233 this . setState ( { modal : toggled } ) ;
226234 }
227235
228236 _handleScrollableDialogCancel ( ) {
229- this . refs . scrollableContentDialog . dismiss ( ) ;
237+ this . setState ( {
238+ showDialogScrollable : false ,
239+ } ) ;
230240 }
231241
232242 _handleScrollableDialogSubmit ( ) {
233- this . refs . scrollableContentDialog . dismiss ( ) ;
243+ this . setState ( {
244+ showDialogScrollable : false ,
245+ } ) ;
234246 }
235247
236248 _handleCustomDialogTouchTap ( ) {
237- this . refs . customDialog . show ( ) ;
249+ this . setState ( {
250+ showDialogScrollable : true ,
251+ } ) ;
238252 }
239253
240254 _handleStandardDialogTouchTap ( ) {
241- this . refs . standardDialog . show ( ) ;
255+ this . setState ( {
256+ showDialogStandardActions : true ,
257+ } ) ;
242258 }
243259
244260 _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+ } ) ;
246273 }
247274
248275}
0 commit comments