Skip to content

Node.js based forum software built for the modern web

fix: pinned topic ordering if parent element has non topic elements

Barış Soner Uşaklıcfedd0877f29
diff --git a/public/src/client/category/tools.js b/public/src/client/category/tools.js
index b98ef26c80..5ec1a8bdb8 100644
--- a/public/src/client/category/tools.js
+++ b/public/src/client/category/tools.js
@@ -314,14 +314,24 @@ define('forum/category/tools', [
baseIndex = parseInt(topicListEl.find('[component="category/topic"].pinned').first().attr('data-index'), 10);
},
update: function (ev, ui) {
+ const tid = ui.item.attr('data-tid');
+ const pinnedTopicEls = topicListEl.find('[component="category/topic"].pinned');
+ let newIndex = 0;
+ pinnedTopicEls.each((index, el) => {
+ if ($(el).attr('data-tid') === tid) {
+ newIndex = index;
+ return false;
+ }
+ });
+
socket.emit('topics.orderPinnedTopics', {
- tid: ui.item.attr('data-tid'),
- order: baseIndex + ui.item.index(),
+ tid: tid,
+ order: baseIndex + newIndex,
}, function (err) {
if (err) {
return alerts.error(err);
}
- topicListEl.find('[component="category/topic"].pinned').each((index, el) => {
+ pinnedTopicEls.each((index, el) => {
$(el).attr('data-index', baseIndex + index);
});
});