Skip to content

Commit

Permalink
fix popovers not closing
Browse files Browse the repository at this point in the history
  • Loading branch information
octavioamu committed Apr 16, 2020
1 parent 8c4f097 commit ab16259
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions app/assets/v2/js/user_card.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
$('body').on('mouseover', '[data-usercard]', function(e) {
openContributorPopOver($(this).data('usercard'), $(this));
}).on('mouseleave', '[data-usercard]', function() {
var _this = this;

setTimeout(function(_this) {
if (!$('.popover-user-card:hover').length) {
$(_this).popover('hide');
}
}, 100);
});

$('body').on('show.bs.popover', '[data-usercard]', function() {
$('body [data-usercard]').not(this).popover('hide');
setTimeout(function() {
if (!$('.popover-user-card:hover').length) {
$(this).popover('hide');
}
}, 100);
});

let popoverData = [];
Expand Down Expand Up @@ -241,7 +254,9 @@ function openContributorPopOver(contributor, element) {
.then(response => {
popoverData.push({ [contributor]: response });
controller = null;
setupPopover(element, response);
if (element.is(':hover')) {
setupPopover(element, response);
}
})
.catch(err => {
return console.warn({ message: err });
Expand All @@ -257,7 +272,6 @@ function setupPopover(element, data) {
return DOMPurify.sanitize(content);
},
placement: 'auto',
// container: element,
trigger: 'manual',
delay: { 'show': 200, 'hide': 500 },
template: `
Expand Down Expand Up @@ -289,5 +303,4 @@ function setupPopover(element, data) {
$(element).popover('show');

addFollowAction();

}

0 comments on commit ab16259

Please sign in to comment.