From c1936e87f0482ac8954d9d919435b40ab5859535 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 26 Aug 2022 10:58:55 -0400 Subject: [PATCH 1/2] fix: add dropup handler to thread tools menu, updated how post tools menu adds dropup handler --- public/src/client/topic.js | 6 ++++++ public/src/client/topic/postTools.js | 8 +++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/public/src/client/topic.js b/public/src/client/topic.js index 0c111bcf7f..5facb841a2 100644 --- a/public/src/client/topic.js +++ b/public/src/client/topic.js @@ -177,6 +177,12 @@ define('forum/topic', [ Topic.applyDropup.call(this); } }); + hooks.onPage('action:topic.tools.load', ({ element }) => { + Topic.applyDropup.call(element.get(0).parentNode); + }); + hooks.onPage('action:post.tools.load', ({ element }) => { + Topic.applyDropup.call(element.get(0).parentNode); + }); } function addRepliesHandler() { diff --git a/public/src/client/topic/postTools.js b/public/src/client/topic/postTools.js index 28b1119a3f..e9b5602145 100644 --- a/public/src/client/topic/postTools.js +++ b/public/src/client/topic/postTools.js @@ -32,7 +32,6 @@ define('forum/topic/postTools', [ function renderMenu() { $('[component="topic"]').on('show.bs.dropdown', '.moderator-tools', function () { - const self = this; const $this = $(this); const dropdownMenu = $this.find('.dropdown-menu'); if (dropdownMenu.html()) { @@ -50,15 +49,14 @@ define('forum/topic/postTools', [ const html = await app.parseAndTranslate('partials/topic/post-menu-list', data); const clipboard = require('clipboard'); - // eslint-disable-next-line import/no-unresolved - const topic = require('forum/topic'); dropdownMenu.html(html); dropdownMenu.get(0).classList.toggle('hidden', false); - topic.applyDropup.call(self); new clipboard('[data-clipboard-text]'); - hooks.fire('action:post.tools.load'); + hooks.fire('action:post.tools.load', { + element: dropdownMenu, + }); }); }); } From a088eb19afc35a1b2478ea2df02903dad1f9c464 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 26 Aug 2022 11:03:04 -0400 Subject: [PATCH 2/2] fix: empty thread tools container on open --- public/src/client/topic/threadTools.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/src/client/topic/threadTools.js b/public/src/client/topic/threadTools.js index 403e9abfba..0a6daa1030 100644 --- a/public/src/client/topic/threadTools.js +++ b/public/src/client/topic/threadTools.js @@ -180,12 +180,15 @@ define('forum/topic/threadTools', [ return; } + dropdownMenu.toggleClass('hidden', true); socket.emit('topics.loadTopicTools', { tid: ajaxify.data.tid, cid: ajaxify.data.cid }, function (err, data) { if (err) { return alerts.error(err); } app.parseAndTranslate('partials/topic/topic-menu-list', data, function (html) { dropdownMenu.html(html); + dropdownMenu.toggleClass('hidden', false); + hooks.fire('action:topic.tools.load', { element: dropdownMenu, });