Skip to content

Commit e8e5eb9

Browse files
committed
Fixed some edge cases for popover triggering
1 parent a15034b commit e8e5eb9

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

src/web/HTMLOperation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ HTMLOperation.prototype.toStubHtml = function(removeIcon) {
5050
let html = "<li class='operation'";
5151

5252
if (this.description) {
53-
html += " data-container='body' data-placement='auto right'\
54-
data-content=\"" + this.description + "\"";
53+
html += " data-container='body' data-toggle='popover' data-placement='auto right'\
54+
data-content=\"" + this.description + "\" data-html='true' data-trigger='hover'";
5555
}
5656

5757
html += ">" + this.name;

src/web/OperationsWaiter.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,31 @@ OperationsWaiter.prototype.getSelectedOp = function(ops) {
155155
*/
156156
OperationsWaiter.prototype.opListCreate = function(e) {
157157
this.manager.recipe.createSortableSeedList(e.target);
158-
// Allows popover to gain focus for eg. pressing buttons/scrolling
159-
$(".operation").popover({trigger: "manual", html: true, animation: true})
160-
.on("mouseenter", function () {
158+
this.enableOpsListPopovers(e.target);
159+
};
160+
161+
162+
/**
163+
* Sets up popovers, allowing the popover itself to gain focus which enables scrolling
164+
* and other interactions.
165+
*
166+
* @param {Element} el - The element to start selecting from
167+
*/
168+
OperationsWaiter.prototype.enableOpsListPopovers = function(el) {
169+
$(el).find("[data-toggle=popover]").addBack("[data-toggle=popover]")
170+
.popover({trigger: "manual"})
171+
.on("mouseenter", function() {
161172
const _this = this;
162173
$(this).popover("show");
163174
$(".popover").on("mouseleave", function () {
164175
$(_this).popover("hide");
165176
});
166177
}).on("mouseleave", function () {
167178
const _this = this;
168-
setTimeout(function () {
169-
if (!$(".popover:hover").length) {
179+
setTimeout(function() {
180+
// Determine if the popover associated with this element is being hovered over
181+
if ($(_this).data("bs.popover") &&
182+
!$(_this).data("bs.popover").$tip.is(":hover")) {
170183
$(_this).popover("hide");
171184
}
172185
}, 50);

src/web/RecipeWaiter.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ RecipeWaiter.prototype.createSortableSeedList = function(listEl) {
9393
// Removes popover element and event bindings from the dragged operation but not the
9494
// event bindings from the one left in the operations list. Without manually removing
9595
// these bindings, we cannot re-initialise the popover on the stub operation.
96-
$(evt.item).popover("destroy");
96+
$(evt.item).popover("destroy").removeData("bs.popover").off("mouseenter").off("mouseleave");
9797
$(evt.clone).off(".popover").removeData("bs.popover");
9898
evt.item.setAttribute("data-toggle", "popover-disabled");
9999
},
@@ -120,8 +120,7 @@ RecipeWaiter.prototype.opSortEnd = function(evt) {
120120

121121
// Reinitialise the popover on the original element in the ops list because for some reason it
122122
// gets destroyed and recreated.
123-
$(evt.clone).popover();
124-
$(evt.clone).children("[data-toggle=popover]").popover();
123+
this.manager.ops.enableOpsListPopovers(evt.clone);
125124

126125
if (evt.item.parentNode.id !== "rec-list") {
127126
return;

0 commit comments

Comments
 (0)