FIX: popover should use target when no data attributes
This commit is contained in:
parent
ca6c919299
commit
0cc81f95a5
|
@ -1,7 +1,8 @@
|
|||
import { showPopover, hidePopover } from "discourse/lib/d-popover";
|
||||
|
||||
const SELECTORS =
|
||||
"[data-html-popover],[data-tooltip],[data-popover],[data-html-tooltip]";
|
||||
import {
|
||||
showPopover,
|
||||
hidePopover,
|
||||
POPOVER_SELECTORS
|
||||
} from "discourse/lib/d-popover";
|
||||
|
||||
export default {
|
||||
name: "d-popover",
|
||||
|
@ -10,12 +11,8 @@ export default {
|
|||
const router = container.lookup("router:main");
|
||||
router.on("routeWillChange", hidePopover);
|
||||
|
||||
$("#main").on("click.d-popover mouseenter.d-popover", SELECTORS, event =>
|
||||
showPopover(event)
|
||||
);
|
||||
|
||||
$("#main").on("mouseleave.d-popover", SELECTORS, event =>
|
||||
hidePopover(event)
|
||||
);
|
||||
$("#main")
|
||||
.on("click.d-popover mouseenter.d-popover", POPOVER_SELECTORS, e => showPopover(e))
|
||||
.on("mouseleave.d-popover", POPOVER_SELECTORS, e => hidePopover(e));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -16,6 +16,8 @@ const D_ARROW_HEIGHT = 10;
|
|||
|
||||
const D_HORIZONTAL_MARGIN = 5;
|
||||
|
||||
export const POPOVER_SELECTORS = "[data-html-popover], [data-html-tooltip], [data-popover], [data-tooltip]";
|
||||
|
||||
export function hidePopover() {
|
||||
getPopover()
|
||||
.fadeOut()
|
||||
|
@ -25,7 +27,13 @@ export function hidePopover() {
|
|||
}
|
||||
|
||||
export function showPopover(event, options = {}) {
|
||||
const $enteredElement = $(event.currentTarget);
|
||||
let $enteredElement = $(event.target)
|
||||
.closest(POPOVER_SELECTORS)
|
||||
.first();
|
||||
|
||||
if (!$enteredElement.length) {
|
||||
$enteredElement = $(event.target);
|
||||
}
|
||||
|
||||
if (isRetina()) {
|
||||
getPopover().addClass("retina");
|
||||
|
|
Loading…
Reference in New Issue