From 8e1da067af8a27ec89401d28d08f0bf91fc57783 Mon Sep 17 00:00:00 2001 From: Megan Thomas Date: Thu, 31 Oct 2024 16:43:57 -0700 Subject: [PATCH] MWPW-160966 Fix next-gen sidekick preflight --- libs/blocks/preflight/panels/seo.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/libs/blocks/preflight/panels/seo.js b/libs/blocks/preflight/panels/seo.js index f240762218..92a94d66dd 100644 --- a/libs/blocks/preflight/panels/seo.js +++ b/libs/blocks/preflight/panels/seo.js @@ -313,15 +313,19 @@ async function getResults() { const icons = [h1, title, canon, desc, body, lorem, links]; const red = icons.find((icon) => icon === 'red'); - if (red) { - const sk = document.querySelector('aem-sidekick, helix-sidekick'); - if (sk) { - const publishBtn = sk.shadowRoot.querySelector('div.publish.plugin button'); - publishBtn.addEventListener('click', () => { - sendResults(); - }); - } - } + if (!red) return; + + const aemSk = document.querySelector('aem-sidekick'); + const hlxSk = document.querySelector('helix-sidekick'); + if (!aemSk && !hlxSk) return; + + const publishBtn = aemSk + ? aemSk.shadowRoot.querySelector('plugin-action-bar').shadowRoot.querySelector('sk-action-button.publish') + : hlxSk.shadowRoot.querySelector('div.publish.plugin button'); + + publishBtn.addEventListener('click', () => { + sendResults(); + }); } export default function Panel() {