From f28923858ecd6cbbd3457d2460fae58d52280c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 22 Apr 2024 10:58:42 -0400 Subject: [PATCH] fix: topic selection in merge if merge was started from inside the topic --- public/src/client/topic/merge.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/public/src/client/topic/merge.js b/public/src/client/topic/merge.js index a2d1131365..7c96f0b9e7 100644 --- a/public/src/client/topic/merge.js +++ b/public/src/client/topic/merge.js @@ -66,11 +66,7 @@ define('forum/topic/merge', ['search', 'alerts', 'api'], function (search, alert callback = callback || function () {}; api.get(`/topics/${tid}`, {}).then(function (topicData) { const title = topicData ? topicData.title : 'No title'; - if (selectedTids[tid]) { - delete selectedTids[tid]; - } else { - selectedTids[tid] = title; - } + selectedTids[tid] = title; checkButtonEnable(); showTopicsSelected(); callback(); @@ -89,8 +85,14 @@ define('forum/topic/merge', ['search', 'alerts', 'api'], function (search, alert if (!modal) { return; } - const tid = $(this).parents('[component="category/topic"]').attr('data-tid'); - Merge.addTopic(tid); + const topicEl = $(this).parents('[component="category/topic"]'); + const isSelected = topicEl.hasClass('selected'); + const tid = topicEl.attr('data-tid'); + if (isSelected) { + Merge.addTopic(tid); + } else { + Merge.removeTopic(tid); + } ev.preventDefault(); ev.stopPropagation();