From 5932770441e92fc532223a03e5e56d9844bc779c Mon Sep 17 00:00:00 2001 From: Sartxi Date: Mon, 16 Sep 2024 10:37:09 -0600 Subject: [PATCH] fix disabled false on button --- libs/utils/sidekick-decorate.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/utils/sidekick-decorate.js b/libs/utils/sidekick-decorate.js index acaa428716..89a87911ae 100644 --- a/libs/utils/sidekick-decorate.js +++ b/libs/utils/sidekick-decorate.js @@ -1,13 +1,17 @@ import userCanPublishPage from '../tools/utils/publish.js'; const PUBLISH_BTN = '.publish.plugin button'; -const BACKUP_PROFILE = '.profile-email'; +const PROFILE = '.profile-email'; const CONFIRM_MESSAGE = 'Are you sure? This will publish to production.'; export default function stylePublish(sk) { const setupPublishBtn = async (page, btn) => { const { canPublish, message } = await userCanPublishPage(page, false); - btn.setAttribute('disabled', !canPublish); + if (canPublish) { + btn.removeAttribute('disabled'); + } else { + btn.setAttribute('disabled', true); + } const messageText = btn.querySelector('span'); const text = canPublish ? CONFIRM_MESSAGE : message; if (messageText) { @@ -94,7 +98,7 @@ export default function stylePublish(sk) { const page = { webPath: window.location.pathname, // added for edge case where the statusfetched event isnt fired on refresh - profile: { email: sk.shadowRoot.querySelector(BACKUP_PROFILE)?.innerText }, + profile: { email: sk.shadowRoot.querySelector(PROFILE)?.innerText }, }; setupPublishBtn(page, btn); }