From 356375677d1a0d250b64829731ed21f927ad706a Mon Sep 17 00:00:00 2001 From: patriceac <48073125+patriceac@users.noreply.github.com> Date: Sat, 25 Mar 2023 02:09:11 -0700 Subject: [PATCH] Fix restoration of disabled image tags Fix a regression introduced by PR 1003 that causes disabled image tags to be restored in an enabled state by the "image modifiers improvements" plugin. No change in the regular UX. --- ui/media/js/image-modifiers.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/media/js/image-modifiers.js b/ui/media/js/image-modifiers.js index a7a030ff..5a56d940 100644 --- a/ui/media/js/image-modifiers.js +++ b/ui/media/js/image-modifiers.js @@ -157,7 +157,7 @@ async function loadModifiers() { document.dispatchEvent(new Event('loadImageModifiers')) } -function refreshModifiersState(newTags) { +function refreshModifiersState(newTags, inactiveTags) { // clear existing modifiers document.querySelector('#editor-modifiers').querySelectorAll('.modifier-card').forEach(modifierCard => { const modifierName = modifierCard.querySelector('.modifier-card-label p').dataset.fullName // pick the full modifier name @@ -211,7 +211,7 @@ function refreshModifiersState(newTags) { }) } }) - refreshTagsList() + refreshTagsList(inactiveTags) } function refreshInactiveTags(inactiveTags) { @@ -228,13 +228,13 @@ function refreshInactiveTags(inactiveTags) { let overlays = document.querySelector('#editor-inputs-tags-list').querySelectorAll('.modifier-card-overlay') overlays.forEach (i => { let modifierName = i.parentElement.getElementsByClassName('modifier-card-label')[0].getElementsByTagName("p")[0].innerText - if (inactiveTags.find(element => element === modifierName) !== undefined) { + if (inactiveTags?.find(element => element === modifierName) !== undefined) { i.parentElement.classList.add('modifier-toggle-inactive') } }) } -function refreshTagsList() { +function refreshTagsList(inactiveTags) { editorModifierTagsList.innerHTML = '' if (activeTags.length == 0) { @@ -266,6 +266,7 @@ function refreshTagsList() { let brk = document.createElement('br') brk.style.clear = 'both' editorModifierTagsList.appendChild(brk) + refreshInactiveTags(inactiveTags) document.dispatchEvent(new Event('refreshImageModifiers')) // notify plugins that the image tags have been refreshed }