Skip to content

Commit

Permalink
Dismiss popover on click instead of mousedown
Browse files Browse the repository at this point in the history
  • Loading branch information
adube committed Feb 8, 2019
1 parent f5c9b8e commit dde1e7a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/message/popoverComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,20 @@ function PopoverController($scope) {
*/
this.bodyElm = undefined;

function onMouseDown(clickEvent) {
function onClick(clickEvent) {
if (this.anchorElm[0] !== clickEvent.target &&
this.bodyElm.parent()[0] !== clickEvent.target &&
this.bodyElm.parent().find(clickEvent.target).length === 0 && this.shown) {
this.dismissPopover();
}
}

angular.element('body').on('mousedown', onMouseDown.bind(this));
const clickHandler = onClick.bind(this)

angular.element('body').on('click', clickHandler);

$scope.$on('$destroy', () => {
angular.element('body').off('mousedown', onMouseDown);
angular.element('body').off('click', clickHandler);
});
}

Expand Down

0 comments on commit dde1e7a

Please sign in to comment.