@@ -286,8 +286,12 @@ public String getTop() {
286
286
}
287
287
288
288
/**
289
- * {@code opened-changed} event is sent when the overlay opened state
290
- * changes.
289
+ * Event that is fired when the dialog's opened state changes.
290
+ * <p>
291
+ * Note that this event fires immediately when the opened property changes,
292
+ * which, when closing the dialog, is before the closing animation has
293
+ * finished. To wait for the animation to finish, listen for the
294
+ * {@link ClosedEvent} event.
291
295
*/
292
296
public static class OpenedChangeEvent extends ComponentEvent <Dialog > {
293
297
private final boolean opened ;
@@ -302,6 +306,17 @@ public boolean isOpened() {
302
306
}
303
307
}
304
308
309
+ /**
310
+ * Event that is fired after the dialog's closing animation has finished.
311
+ * Can be used to remove a dialog from the UI afterward.
312
+ */
313
+ @ DomEvent ("closed" )
314
+ public static class ClosedEvent extends ComponentEvent <Dialog > {
315
+ public ClosedEvent (Dialog source , boolean fromClient ) {
316
+ super (source , fromClient );
317
+ }
318
+ }
319
+
305
320
@ Override
306
321
public void setWidth (String value ) {
307
322
getElement ().setProperty ("width" , value );
@@ -969,7 +984,12 @@ private void setModality(boolean modal) {
969
984
}
970
985
971
986
/**
972
- * Add a lister for event fired by the {@code opened-changed} events.
987
+ * Add a listener for when the dialog's opened state changes.
988
+ * <p>
989
+ * Note that this event fires immediately when the opened property changes,
990
+ * which, when closing the dialog, is before the closing animation has
991
+ * finished. To wait for the animation to finish, use
992
+ * {@link #addClosedListener(ComponentEventListener)}.
973
993
*
974
994
* @param listener
975
995
* the listener to add
@@ -980,6 +1000,19 @@ public Registration addOpenedChangeListener(
980
1000
return addListener (OpenedChangeEvent .class , listener );
981
1001
}
982
1002
1003
+ /**
1004
+ * Add a lister for when the dialog's closing animation has finished. Can be
1005
+ * used to remove the dialog from the UI afterward.
1006
+ *
1007
+ * @param listener
1008
+ * the listener to add
1009
+ * @return a Registration for removing the event listener
1010
+ */
1011
+ public Registration addClosedListener (
1012
+ ComponentEventListener <ClosedEvent > listener ) {
1013
+ return addListener (ClosedEvent .class , listener );
1014
+ }
1015
+
983
1016
/**
984
1017
* {@inheritDoc}
985
1018
* <p>
@@ -996,8 +1029,8 @@ public Registration addAttachListener(
996
1029
* {@inheritDoc}
997
1030
* <p>
998
1031
* Note: To listen for closing the dialog, you should use
999
- * {@link #addOpenedChangeListener (ComponentEventListener)}, as the
1000
- * component is not necessarily removed from the DOM when closing.
1032
+ * {@link #addClosedListener (ComponentEventListener)}, as the component is
1033
+ * not necessarily removed from the DOM when closing.
1001
1034
*/
1002
1035
@ Override
1003
1036
public Registration addDetachListener (
0 commit comments