Skip to content

Commit

Permalink
FIX: tooltip regression in admin dashboard
Browse files Browse the repository at this point in the history
- adds registerHoverTooltip in tooltip qunit test
  • Loading branch information
pmusaraj committed Dec 3, 2018
1 parent 1a4676c commit 923692d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions app/assets/javascripts/discourse/lib/tooltip.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { escapeExpression } from "discourse/lib/utilities";
const fadeSpeed = 300;
const tooltipID = "#discourse-tooltip";

export function showTooltip($this) {
const $parent = $this.offsetParent();
export function showTooltip(e) {
const $this = $(e.currentTarget),
$parent = $this.offsetParent();
// html tooltip are risky try your best to sanitize anything
// displayed as html to avoid XSS attacks
const content = $this.attr("data-tooltip")
Expand Down Expand Up @@ -77,9 +78,7 @@ export function hideTooltip() {

export function registerTooltip(jqueryContext) {
if (jqueryContext.length) {
jqueryContext
.off("click")
.on("click", event => showTooltip($(event.currentTarget)));
jqueryContext.off("click").on("click", event => showTooltip(event));
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/javascripts/lib/tooltip-test.js.es6
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { registerTooltip } from "discourse/lib/tooltip";
import { registerTooltip, registerHoverTooltip } from "discourse/lib/tooltip";

// prettier-ignore
QUnit.module("lib:tooltip", {
Expand Down Expand Up @@ -37,7 +37,7 @@ QUnit.test("text support", async assert => {

QUnit.test("html support", async assert => {
const $testHtmlLink = fixture(".test-html-link");
registerTooltip($testHtmlLink);
registerHoverTooltip($testHtmlLink);

await $testHtmlLink.click();

Expand Down

1 comment on commit 923692d

@discoursebot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/question-marks-on-new-dashboard-broken/103360/3

Please sign in to comment.