From 613523c9b4f5953506e13f8a5275aa9c1c633bd7 Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Mon, 20 Jun 2022 16:53:11 +0100 Subject: [PATCH] fix(tags): tag selection modal shown when no tags can be selected (#3448) --- extensions/tags/js/src/forum/addTagComposer.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/extensions/tags/js/src/forum/addTagComposer.js b/extensions/tags/js/src/forum/addTagComposer.js index 51b643985..ffd930f40 100644 --- a/extensions/tags/js/src/forum/addTagComposer.js +++ b/extensions/tags/js/src/forum/addTagComposer.js @@ -65,10 +65,15 @@ export default function () { const chosenSecondaryTags = chosenTags.filter((tag) => tag.position() === null); const selectableTags = getSelectableTags(); + const minPrimaryTags = parseInt(app.forum.attribute('minPrimaryTags')); + const minSecondaryTags = parseInt(app.forum.attribute('minSecondaryTags')); + const maxPrimaryTags = parseInt(app.forum.attribute('maxPrimaryTags')); + const maxSecondaryTags = parseInt(app.forum.attribute('maxSecondaryTags')); + if ( - (!chosenTags.length || - chosenPrimaryTags.length < app.forum.attribute('minPrimaryTags') || - chosenSecondaryTags.length < app.forum.attribute('minSecondaryTags')) && + ((!chosenTags.length && maxPrimaryTags !== 0 && maxSecondaryTags !== 0) || + chosenPrimaryTags.length < minPrimaryTags || + chosenSecondaryTags.length < minSecondaryTags) && selectableTags.length ) { app.modal.show(TagDiscussionModal, {