|
|
@@ -28,8 +28,7 @@ const OK_BUTTON_ID = 'modal-dialog-ok-button';
|
|
28
|
28
|
*
|
|
29
|
29
|
* @static
|
|
30
|
30
|
*/
|
|
31
|
|
-type Props = {
|
|
32
|
|
- ...DialogProps,
|
|
|
31
|
+type Props = DialogProps & {
|
|
33
|
32
|
|
|
34
|
33
|
/**
|
|
35
|
34
|
* Custom dialog header that replaces the standard heading.
|
|
|
@@ -77,6 +76,11 @@ type Props = {
|
|
77
|
76
|
*/
|
|
78
|
77
|
onDecline?: Function,
|
|
79
|
78
|
|
|
|
79
|
+ /**
|
|
|
80
|
+ * Callback invoked when setting the ref of the Dialog.
|
|
|
81
|
+ */
|
|
|
82
|
+ onDialogRef?: Function,
|
|
|
83
|
+
|
|
80
|
84
|
/**
|
|
81
|
85
|
* Disables rendering of the submit button.
|
|
82
|
86
|
*/
|
|
|
@@ -127,7 +131,7 @@ class StatelessDialog extends Component<Props> {
|
|
127
|
131
|
this._onKeyPress = this._onKeyPress.bind(this);
|
|
128
|
132
|
this._onSubmit = this._onSubmit.bind(this);
|
|
129
|
133
|
this._renderFooter = this._renderFooter.bind(this);
|
|
130
|
|
- this._setDialogElement = this._setDialogElement.bind(this);
|
|
|
134
|
+ this._onDialogRef = this._onDialogRef.bind(this);
|
|
131
|
135
|
}
|
|
132
|
136
|
|
|
133
|
137
|
/**
|
|
|
@@ -166,7 +170,7 @@ class StatelessDialog extends Component<Props> {
|
|
166
|
170
|
width = { width || 'medium' }>
|
|
167
|
171
|
<div
|
|
168
|
172
|
onKeyPress = { this._onKeyPress }
|
|
169
|
|
- ref = { this._setDialogElement }>
|
|
|
173
|
+ ref = { this._onDialogRef }>
|
|
170
|
174
|
<form
|
|
171
|
175
|
className = 'modal-dialog-form'
|
|
172
|
176
|
id = 'modal-dialog-form'
|
|
|
@@ -319,19 +323,18 @@ class StatelessDialog extends Component<Props> {
|
|
319
|
323
|
);
|
|
320
|
324
|
}
|
|
321
|
325
|
|
|
322
|
|
- _setDialogElement: (?HTMLElement) => void;
|
|
|
326
|
+ _onDialogRef: (?Element) => void;
|
|
323
|
327
|
|
|
324
|
328
|
/**
|
|
325
|
|
- * Sets the instance variable for the div containing the component's dialog
|
|
326
|
|
- * element so it can be accessed directly.
|
|
|
329
|
+ * Callback invoked when setting the ref of the dialog's child passing the Modal ref.
|
|
|
330
|
+ * It is done this way because we cannot directly access the ref of the Modal component.
|
|
327
|
331
|
*
|
|
328
|
|
- * @param {HTMLElement} element - The DOM element for the component's
|
|
329
|
|
- * dialog.
|
|
|
332
|
+ * @param {HTMLElement} element - The DOM element for the dialog.
|
|
330
|
333
|
* @private
|
|
331
|
334
|
* @returns {void}
|
|
332
|
335
|
*/
|
|
333
|
|
- _setDialogElement(element: ?HTMLElement) {
|
|
334
|
|
- this._dialogElement = element;
|
|
|
336
|
+ _onDialogRef(element: ?Element) {
|
|
|
337
|
+ this.props.onDialogRef && this.props.onDialogRef(element && element.parentNode);
|
|
335
|
338
|
}
|
|
336
|
339
|
|
|
337
|
340
|
_onKeyPress: (Object) => void;
|