Skip to content

[MWPW-199709] Conditionally hide Register CTA in C2 GNAV based on registration status - #191

Open
maagrawal16 wants to merge 6 commits into
stagefrom
MWPW-199709
Open

[MWPW-199709] Conditionally hide Register CTA in C2 GNAV based on registration status#191
maagrawal16 wants to merge 6 commits into
stagefrom
MWPW-199709

Conversation

@maagrawal16

@maagrawal16 maagrawal16 commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Added first-class support in the C2 GNAV library for hiding a CTA (e.g. MAX'26's "Register" button) once the visitor is confirmed registered for the event.

How it works

  • Authoring — append #_hide-when-registered to the CTA's link href in DA, the same lightweight convention as the existing #_blank suffix. No new authoring UI.
  • RenderprimaryCTA/secondaryCTA strip the suffix (keeping the real URL clean) and stamp a data-feds-hide-when-registered marker on the anchor.
  • Gating — after render, initEventRegistrationGating consumes the events platform's registration signal and removes the CTA's wrapper (<li> or .feds-product-entry-cta, falling back to the link itself) when isRegistered is true.

Registration signal — event-driven

Verified against da-events registration-cache.js: the platform dispatches registration:resolved on window (detail { isRegistered, inPersonAttendee }) before it assigns window.events. GNAV can render on either side of that, so the gating uses a race-free check-else-listen:

  • rendered late → window.events already exists, call getRegistrationStatus() directly;
  • rendered early → subscribe once to registration:resolved and read event.detail.

Because the event fires before window.events is assigned, a synchronous "is window.events there?" check that sees nothing proves the event hasn't fired yet, so the { once: true } listener will catch it.

Scope / safety

  • Gated entirely behind event-code metadata — non-event pages (the vast majority of adobe.com using this shared GNAV) short-circuit after metadata read and never touch window.events.
  • Fire-and-forget: never awaited in GNAV's render/promise path, so nav LCP/TBT are unaffected.
  • No new network calls — rides on da-events' already-memoized/cached lookup.

Files

  • src/Utils/Utils.tsgetRegistrationGateAttrs helper + HIDE_WHEN_REGISTERED_SUFFIX
  • src/Components/CTA/Render.ts — stamps the data-feds-hide-when-registered marker
  • src/types/adobe-window.d.ts — types the window.events global
  • src/PostRendering/EventRegistration.ts — the event-driven gating logic (new)
  • src/Main.ts — wires initEventRegistrationGating into postRenderingTasks
  • dist/main.js / dist/main.js.map — rebuilt bundle
  • Tests — test/Utils/RegistrationGate.test.js, test/Components/CTA/Render.test.js, test/PostRendering/EventRegistration.test.js

Testing

  • Unit: full suite green (261 passing), lint + typecheck clean.
  • Manual: verified end-to-end with two real accounts on the test page:
    • Registeredvevent+max2025-registered@adobetest.com (provided by hnv@adobe.com): Register CTA is hidden.
    • Not registeredmaagrawal@adobe.com (my own LDAP): Register CTA remains visible.

Test pages:

@aem-code-sync

aem-code-sync Bot commented Aug 19, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run all PSI checks
  • Re-run failed PSI checks
  • Re-sync branch
Commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants