From 2a77550f8c90400d78d2cb8fee3620f3deff6a2a Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Thu, 25 Oct 2018 12:46:05 +0300 Subject: [PATCH] FIX: Do not track right clicks. (#6530) --- app/assets/javascripts/discourse/lib/click-track.js.es6 | 5 +++++ test/javascripts/lib/click-track-test.js.es6 | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/app/assets/javascripts/discourse/lib/click-track.js.es6 b/app/assets/javascripts/discourse/lib/click-track.js.es6 index c638cd73026..1ce5493902e 100644 --- a/app/assets/javascripts/discourse/lib/click-track.js.es6 +++ b/app/assets/javascripts/discourse/lib/click-track.js.es6 @@ -13,6 +13,11 @@ export function isValidLink($link) { export default { trackClick(e) { + // right clicks are not tracked + if (e.which === 3) { + return true; + } + // cancel click if triggered as part of selection. if (selectedText() !== "") { return false; diff --git a/test/javascripts/lib/click-track-test.js.es6 b/test/javascripts/lib/click-track-test.js.es6 index c1aa8b1e56e..06cc38cba46 100644 --- a/test/javascripts/lib/click-track-test.js.es6 +++ b/test/javascripts/lib/click-track-test.js.es6 @@ -69,6 +69,12 @@ QUnit.test("does not track clicks on back buttons", assert => { assert.ok(track(generateClickEventOn(".back"))); }); +QUnit.test("does not track right clicks inside quotes", assert => { + const event = generateClickEventOn(".quote a:first-child"); + event.which = 3; + assert.ok(track(event)); +}); + QUnit.test("does not track clicks to internal links in quotes", assert => { sandbox.stub(DiscourseURL, "routeTo"); sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");