@@ -36,31 +36,35 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
3636 static dialogCounter = 0 ;
3737 /**
3838 * Title for the dialog
39- * @type {string }
4039 */
4140 @Input ( ) title = "" ;
4241 /**
4342 * Dialog body content.
44- * @type {(string | TemplateRef<any>) }
4543 */
4644 @Input ( ) ibmDialog : string | TemplateRef < any > ;
4745 /**
4846 * Defines how the Dialog is triggered.(Hover and click behave the same on mobile - both respond to a single tap)
49- * @type {("click" | "hover" | "mouseenter") }
5047 */
5148 @Input ( ) trigger : "click" | "hover" | "mouseenter" = "click" ;
49+ /**
50+ * Defines how the Dialog close event is triggered.
51+ *
52+ * [See here](https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseleave_event)
53+ * for more on the difference between `mouseleave` and `mouseout`.
54+ *
55+ * Defaults to `click` when `trigger` is set to `click`.
56+ */
57+ @Input ( ) closeTrigger : "mouseout" | "mouseleave" = "mouseleave" ;
5258 /**
5359 * Placement of the dialog, usually relative to the element the directive is on.
5460 */
5561 @Input ( ) placement = "left" ;
5662 /**
5763 * Class to add to the dialog container
58- * @type {string }
5964 */
6065 @Input ( ) wrapperClass : string ;
6166 /**
6267 * Spacing between the dialog and it's triggering element
63- * @type {number }
6468 */
6569 @Input ( ) gap = 0 ;
6670 /**
@@ -117,7 +121,6 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
117121
118122 /**
119123 * Overrides 'touchstart' event to trigger a toggle on the Dialog.
120- * @param {any } evt
121124 */
122125 @HostListener ( "touchstart" , [ "$event" ] )
123126 onTouchStart ( evt ) {
@@ -135,6 +138,7 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
135138 parentRef : this . elementRef ,
136139 gap : this . gap ,
137140 trigger : this . trigger ,
141+ closeTrigger : this . closeTrigger ,
138142 appendInline : this . appendInline ,
139143 wrapperClass : this . wrapperClass ,
140144 data : this . data
@@ -160,7 +164,7 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
160164 // bind events for hovering or clicking the host
161165 if ( this . trigger === "hover" || this . trigger === "mouseenter" ) {
162166 fromEvent ( this . elementRef . nativeElement , "mouseenter" ) . subscribe ( ( ) => this . toggle ( ) ) ;
163- fromEvent ( this . elementRef . nativeElement , "mouseout" ) . subscribe ( ( ) => this . close ( ) ) ;
167+ fromEvent ( this . elementRef . nativeElement , this . closeTrigger ) . subscribe ( ( ) => this . close ( ) ) ;
164168 fromEvent ( this . elementRef . nativeElement , "focus" ) . subscribe ( ( ) => this . open ( ) ) ;
165169 fromEvent ( this . elementRef . nativeElement , "blur" ) . subscribe ( ( ) => this . close ( ) ) ;
166170 } else {
@@ -231,7 +235,6 @@ export class DialogDirective implements OnInit, OnDestroy, OnChanges {
231235 /**
232236 * Empty method for child classes to override and specify additional init steps.
233237 * Run after DialogDirective completes it's ngOnInit.
234- * @protected
235238 */
236239 protected onDialogInit ( ) { }
237240}
0 commit comments