diff --git a/src/0_config.js b/src/0_config.js index 12e7d959..aab3670c 100644 --- a/src/0_config.js +++ b/src/0_config.js @@ -9,4 +9,4 @@ config.app_service_endpoint = 'https://app.link'; config.link_service_endpoint = 'https://bnc.lt'; config.api_endpoint = DEFAULT_API_ENDPOINT; // will get overwritten by gha on actual deploy -config.version = '2.85.2'; +config.version = '2.86.1'; diff --git a/src/journeys_utils.js b/src/journeys_utils.js index 19560e55..8425cc28 100644 --- a/src/journeys_utils.js +++ b/src/journeys_utils.js @@ -248,7 +248,8 @@ journeys_utils.createIframe = function() { iframe.scrolling = 'no'; iframe.id = 'branch-banner-iframe'; iframe.className = 'branch-animation'; - iframe.setAttribute('tabindex', '-1'); + iframe.title = 'Branch Banner Frame'; + iframe.setAttribute('aria-label', 'Branch Banner Frame'); utils.addNonceAttribute(iframe); return iframe; @@ -286,36 +287,52 @@ journeys_utils.addHtmlToIframe = function(iframe, html, userAgent) { var focusableContent = modal.querySelectorAll(focusableElements); var focusElementIdx = 0; - function handleTabKey(e) { + function handleKeyboardNavigation(e) { var isTabPressed = e.key === 'Tab' || e.keyCode === 9; - - if (!isTabPressed) { - return; - } - - if (e.shifKey) { - if (focusElementIdx <= 0) { - focusElementIdx = focusableContent.length - 1; + var isEnterPressed = e.key === 'Enter' || e.keyCode === 13; + + // Handle Tab key for focus navigation + if (isTabPressed) { + if (e.shiftKey) { + if (focusElementIdx <= 0) { + focusElementIdx = focusableContent.length - 1; + } else { + focusElementIdx = focusElementIdx - 1; + } } else { - focusElementIdx = focusElementIdx - 1; + if (focusElementIdx >= focusableContent.length - 1) { + focusElementIdx = 0; + } else { + focusElementIdx = focusElementIdx + 1; + } } - } else { - if (focusElementIdx >= focusableContent.length - 1) { - focusElementIdx = 0; - } else { - focusElementIdx = focusElementIdx + 1; + + focusableContent[focusElementIdx].focus(); + e.preventDefault(); + return; + } + + // Handle Enter key for activation + if (isEnterPressed) { + // Get the currently focused element + var focusedElement = document.activeElement; + if (focusedElement && ( + focusedElement.tagName === 'BUTTON' || + focusedElement.getAttribute('role') === 'button' || + focusedElement.tagName === 'A' + )) { + // Simulate a click on the element + focusedElement.click(); + e.preventDefault(); } } - - focusableContent[focusElementIdx].focus(); - e.preventDefault(); } function autoFocus(delay) { setTimeout(function() { focusableContent[focusElementIdx].focus() }, delay); } - document.addEventListener('keydown', handleTabKey); + document.addEventListener('keydown', handleKeyboardNavigation); autoFocus(100); `; diff --git a/test/web-config.js b/test/web-config.js index 0f5d97b1..4257ea31 100644 --- a/test/web-config.js +++ b/test/web-config.js @@ -7,4 +7,4 @@ config.app_service_endpoint = 'https://app.link'; config.link_service_endpoint = 'https://bnc.lt'; config.api_endpoint = 'https://api.branch.io'; // will get overwritten by gha on actual deploy -config.version = '2.85.2'; +config.version = '2.86.1';