Skip to content

Commit

Permalink
On Video close events and modal window close events , send adobe_corp…
Browse files Browse the repository at this point in the history
…new.digitalData in the alloy call (#1998)

* Add support for bold as header if no header

* Add tracking to modal close button

* separate branches

* include the word modal in analytic

* Changing name to match old analytic and removing old

* unit test update to new name

* conflict resolved
  • Loading branch information
vgoodric authored Apr 1, 2024
1 parent a64b443 commit cf964ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 7 additions & 6 deletions libs/blocks/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ export function closeModal(modal) {
const { id } = modal;
const closeEvent = new Event('milo:modal:closed');
window.dispatchEvent(closeEvent);
const localeModal = id?.includes('locale-modal') ? 'localeModal' : 'milo';
const analyticsEventName = window.location.hash ? window.location.hash.replace('#', '') : localeModal;
const closeEventAnalytics = new Event(`${analyticsEventName}:modalClose:buttonClose`);

sendAnalytics(closeEventAnalytics);

document.querySelectorAll(`#${id}`).forEach((mod) => {
if (mod.classList.contains('dialog-modal')) {
Expand Down Expand Up @@ -102,7 +97,13 @@ export async function getModal(details, custom) {
if (custom) getCustomModal(custom, dialog);
if (details) await getPathModal(details.path, dialog);

const close = createTag('button', { class: 'dialog-close', 'aria-label': 'Close' }, CLOSE_ICON);
const localeModal = id?.includes('locale-modal') ? 'localeModal' : 'milo';
const analyticsEventName = window.location.hash ? window.location.hash.replace('#', '') : localeModal;
const close = createTag('button', {
class: 'dialog-close',
'aria-label': 'Close',
'daa-ll': `${analyticsEventName}:modalClose:buttonClose`,
}, CLOSE_ICON);

const focusVisible = { focusVisible: true };
const focusablesOnLoad = [...dialog.querySelectorAll(FOCUSABLES)];
Expand Down
1 change: 1 addition & 0 deletions test/blocks/modals/modals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('Modals', () => {
window.location.hash = '#milo';
await waitForElement('#milo');
const close = document.querySelector('.dialog-close');
expect(close.getAttribute('daa-ll')).to.equal('milo:modalClose:buttonClose');
close.click();
await waitForRemoval('#milo');
expect(window.location.hash).to.be.empty;
Expand Down

0 comments on commit cf964ca

Please sign in to comment.