Skip to content

Commit

Permalink
fix(tags): tag selection modal shown when no tags can be selected
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Jun 20, 2022
1 parent 3e56bd3 commit f608cb8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions extensions/tags/js/src/forum/addTagComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit f608cb8

Please sign in to comment.