From 666e0eaff9ad3ef842b00847733fc6f1ad8ee1e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 26 Jul 2019 20:35:45 -0400 Subject: [PATCH] fix: #7798, fix nested post selection --- public/src/modules/postSelect.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/public/src/modules/postSelect.js b/public/src/modules/postSelect.js index a44420e2d3..d2ca3ff81c 100644 --- a/public/src/modules/postSelect.js +++ b/public/src/modules/postSelect.js @@ -18,8 +18,14 @@ define('postSelect', ['components'], function (components) { disableClicksOnPosts(); }; - function onPostClicked() { - PostSelect.togglePostSelection($(this)); + function onPostClicked(ev) { + ev.stopPropagation(); + var pidClicked = $(this).attr('data-pid'); + var postEls = $('[component="topic"] [data-pid="' + pidClicked + '"]'); + if (!allowMainPostSelect && parseInt($(this).attr('data-index'), 10) === 0) { + return; + } + PostSelect.togglePostSelection(postEls, pidClicked); } PostSelect.disable = function () { @@ -31,21 +37,15 @@ define('postSelect', ['components'], function (components) { enableClicksOnPosts(); }; - PostSelect.togglePostSelection = function (post) { - var newPid = post.attr('data-pid'); - - if (!allowMainPostSelect && parseInt(post.attr('data-index'), 10) === 0) { - return; - } - - if (newPid) { - var index = PostSelect.pids.indexOf(newPid); + PostSelect.togglePostSelection = function (postEls, pid) { + if (pid) { + var index = PostSelect.pids.indexOf(pid); if (index === -1) { - PostSelect.pids.push(newPid); - post.toggleClass('bg-success', true); + PostSelect.pids.push(pid); + postEls.toggleClass('bg-success', true); } else { PostSelect.pids.splice(index, 1); - post.toggleClass('bg-success', false); + postEls.toggleClass('bg-success', false); } if (PostSelect.pids.length) { @@ -57,7 +57,6 @@ define('postSelect', ['components'], function (components) { } }; - function disableClicks() { return false; }