Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/0_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
57 changes: 37 additions & 20 deletions src/journeys_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

`;
Expand Down
2 changes: 1 addition & 1 deletion test/web-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';