Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
feat: ability to control whether outside clicks will close a click-tr…
Browse files Browse the repository at this point in the history
…iggered contextual container
  • Loading branch information
mdeanjones committed Dec 29, 2022
1 parent badd9ec commit 8cb00d5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions addon/components/-internals/contextual-container/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ export default class UiContextualContainer extends Component {
*/
public visible = false;

/**
* When triggerEvents = CLICK, this controls whether interacting with elements
* outside the positioned or triggering elements will cause the positioned
* element to be hidden.
*/
public closeOnOutsideClick = true;

/**
* The amount of time, in milliseconds, between the trigger event occurring
* and the positioned element being shown or hidden. This value is applied
Expand Down Expand Up @@ -580,11 +587,13 @@ export default class UiContextualContainer extends Component {
outsideClickTargets.push(this.triggerElement);
}

this.handleOutsideClick = createOutsideClickListener(
this,
outsideClickTargets,
this.handleToggle
);
if (this.closeOnOutsideClick) {
this.handleOutsideClick = createOutsideClickListener(
this,
outsideClickTargets,
this.handleToggle
);
}
}
}

Expand Down

0 comments on commit 8cb00d5

Please sign in to comment.