From 80745b81c9c28d1da34fa7354872b2649b94e12f Mon Sep 17 00:00:00 2001 From: Justin DiRose Date: Wed, 5 Aug 2020 12:02:09 -0500 Subject: [PATCH] FIX: Improve topic link click handling The way we were handling clicks were not always passing topic ids to the model. This should improve the flow and make it more consistent. --- .../knowledge-explorer-topic-list.js.es6 | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/assets/javascripts/discourse/components/knowledge-explorer-topic-list.js.es6 b/assets/javascripts/discourse/components/knowledge-explorer-topic-list.js.es6 index 33e9653..fe8048e 100644 --- a/assets/javascripts/discourse/components/knowledge-explorer-topic-list.js.es6 +++ b/assets/javascripts/discourse/components/knowledge-explorer-topic-list.js.es6 @@ -13,16 +13,10 @@ export default Ember.Component.extend({ }, // need to handle clicks here since links are in a raw view - didRender() { - const topicLinks = this.element.getElementsByClassName( - "knowledge-explorer-topic-link" - ); - - for (let i = 0, max = topicLinks.length; i < max; i++) { - topicLinks[i].addEventListener("click", e => { - const topicId = e.target.dataset.topicId; - this.selectTopic(topicId); - }); + click(e) { + if (e.target.className === "knowledge-explorer-topic-link") { + const topicId = e.target.dataset.topicId; + this.selectTopic(topicId); } },