Skip to content

Conversation

@bredmond5
Copy link
Contributor

@bredmond5 bredmond5 commented Jun 27, 2025

Pull Request Template

Description

A customer's automation has found our journeys to not be WCAG compliant because our iframe that we load the journey into has tabindex = -1.

What they think this is doing is making it so that the user can not tab into the journey using the keyboard. The real issues are as follows:

Issue 1: CSS in the journey template
at the bottom of the template (this being the template in the dashboard that the customer has the ability to edit)

*:focus {
  outline: none !important;
}

what this is doing is making it so that when the journey is tabbed onto, you dont actually see what is being highlighted. In my own template, I updated it to

*:focus {
  outline: 2px solid blue;
}

and now i can see that when tabbing i am actually highlighting onto various parts of the journey.

Issue 2: our handling of keyboard input on the journey

We created special logic to handle tabs in the journey. This function though is handling all keyboard input. So, since it is handling all keyboard input, including enter, but without any specific way to handle enter, then pressing the enter key will not do anything

So, i fix the issue of keyboard input in this PR. I also removed the tabindex and added some other WCAG tags because they dont change anything, but will hopefully make the customer happy.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit test
  • Integration test

JS Budget Check

Please mention the size in kb before abd after this PR

Files Before After
dist/build.js.
dist/build.min.js

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Mentions:

List the person or team responsible for reviewing proposed changes.

cc @BranchMetrics/saas-sdk-devs for visibility.

@matter-code-review
Copy link

matter-code-review bot commented Jun 27, 2025

Code Quality bug fix new feature accessibility

Pull Request Template

Description

Summary By MatterAI MatterAI logo

🔄 What Changed

This pull request primarily focuses on enhancing the accessibility of embedded iframes and updating the library version. Key changes include:

  • Version Bump: Updated the config.version from 2.85.2 to 2.86.1 in src/0_config.js and test/web-config.js.
  • Accessibility Improvements: In src/journeys_utils.js, the createIframe function now adds title="Branch Banner Frame" and aria-label="Branch Banner Frame" attributes to the iframe for better screen reader compatibility.
  • Enhanced Keyboard Navigation: The addHtmlToIframe function has been significantly refactored to improve keyboard accessibility within modal content. The handleTabKey function was renamed to handleKeyboardNavigation and extended to handle both Tab key (for focus cycling) and Enter key (for activating focused buttons/links).

🔍 Impact of the Change

  • Improved User Experience: Users relying on keyboard navigation or assistive technologies will have a much smoother experience interacting with embedded banners and modals, as focus can now be properly cycled and interactive elements can be activated via the Enter key.
  • Accessibility Compliance: The addition of title and aria-label attributes to the iframe improves compliance with accessibility standards.
  • Version Update: Reflects the latest version of the library.

📁 Total Files Changed

3 files were changed in this pull request.

🧪 Test Added

No specific tests were explicitly added or mentioned in the provided patch or PR description for the new keyboard navigation logic. The PR does not include new test files or modifications to existing test files to cover the accessibility enhancements.

🔒Security Vulnerabilities

No new security vulnerabilities were detected in the provided code changes. The accessibility improvements are a positive change and do not introduce any known security risks.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Unit test
  • Integration test

N/A - No specific tests or testing instructions were provided in the pull request description.

JS Budget Check

Please mention the size in kb before abd after this PR

Files Before After
dist/build.js. N/A N/A
dist/build.min.js N/A N/A

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Mentions:

List the person or team responsible for reviewing proposed changes.

cc @BranchMetrics/saas-sdk-devs for visibility.

Tip

Quality Recommendations

  1. Consider refactoring the handleKeyboardNavigation function into smaller, more focused functions (e.g., handleTabNavigation, handleEnterNavigation) to improve readability and maintainability, as it currently handles two distinct keyboard actions.

  2. Add dedicated unit tests for the new keyboard navigation logic within handleKeyboardNavigation to ensure robust behavior across all edge cases, such as tabbing forward/backward at the start/end of focusable elements, and activating different types of interactive elements with the Enter key.

  3. While the focusableElements selector is common, ensure it is comprehensive enough to cover all potential interactive elements that might appear within the modal, including custom elements or elements with specific ARIA roles that might not be explicitly listed.

Sequence Diagram

sequenceDiagram
    participant ClientApp
    participant journeys_utils
    participant Iframe
    participant Document
    participant User

    ClientApp->>journeys_utils: Call createIframe()
    journeys_utils-->>Iframe: Create iframe element (id: 'branch-banner-iframe', title: 'Branch Banner Frame', aria-label: 'Branch Banner Frame')
    journeys_utils-->>ClientApp: Return iframe element

    ClientApp->>journeys_utils: Call addHtmlToIframe(iframe, html, userAgent)
    journeys_utils->>Iframe: Inject HTML content
    journeys_utils->>Document: Add keydown event listener (handleKeyboardNavigation)
    journeys_utils->>Iframe: autoFocus(100) on initial focusable element

    User->>Document: Press keyboard key (e.g., Tab, Enter)
    Document->>journeys_utils: Trigger handleKeyboardNavigation(event)

    alt If Tab key is pressed (event.key === 'Tab' || event.keyCode === 9)
        journeys_utils->>journeys_utils: Determine next/previous focusable element index (focusElementIdx) based on shiftKey
        journeys_utils->>Iframe: focusableContent[focusElementIdx].focus()
        journeys_utils->>Document: event.preventDefault()
    else If Enter key is pressed (event.key === 'Enter' || event.keyCode === 13)
        journeys_utils->>Document: Get activeElement (focusedElement)
        alt If focusedElement is a Button, A, or has role='button'
            journeys_utils->>focusedElement: Simulate click()
            journeys_utils->>Document: event.preventDefault()
        end
    end
Loading

@matter-code-review
Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@matter-code-review
Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@github-actions
Copy link
Contributor

github-actions bot commented Jun 27, 2025

Test Results

  1 files  ±0    1 suites  ±0   55s ⏱️ -1s
159 tests ±0  152 ✅ ±0  7 💤 ±0  0 ❌ ±0 
162 runs  ±0  155 ✅ ±0  7 💤 ±0  0 ❌ ±0 

Results for commit 8995695. ± Comparison against base commit 3a65201.

♻️ This comment has been updated with latest results.

@gdeluna-branch
Copy link

/matter review

Copy link

@matter-code-review matter-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds keyboard navigation support for modal dialogs, improving accessibility. The implementation looks good overall with a few minor improvements suggested below.

Comment on lines 294 to 301
if (isTabPressed) {
console.log("tab pressed");
if (e.shiftKey) {
if (focusElementIdx <= 0) {
focusElementIdx = focusableContent.length - 1;
} else {
focusElementIdx = focusElementIdx - 1;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Code Refactor

Issue: Console.log statements should not be included in production code as they can expose information and impact performance.
Fix: Remove the console.log debug statements.
Impact: Improves code cleanliness and prevents potential information leakage in production.

Suggested change
if (isTabPressed) {
console.log("tab pressed");
if (e.shiftKey) {
if (focusElementIdx <= 0) {
focusElementIdx = focusableContent.length - 1;
} else {
focusElementIdx = focusElementIdx - 1;
}
if (isTabPressed) {
if (e.shiftKey) {
if (focusElementIdx <= 0) {
focusElementIdx = focusableContent.length - 1;
} else {
focusElementIdx = focusElementIdx - 1;
}

Comment on lines 316 to 318
if (isEnterPressed) {
console.log("enter pressed");
// Get the currently focused element
var focusedElement = document.activeElement;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Code Refactor

Issue: Console.log statements should not be included in production code as they can expose information and impact performance.
Fix: Remove the console.log debug statement.
Impact: Improves code cleanliness and prevents potential information leakage in production.

Suggested change
if (isEnterPressed) {
console.log("enter pressed");
// Get the currently focused element
var focusedElement = document.activeElement;
if (isEnterPressed) {
// Get the currently focused element
var focusedElement = document.activeElement;

obj = utils.addPropertyIfNotNull(obj, 'no_journeys', options['no_journeys']);
obj = utils.addPropertyIfNotNull(obj, 'is_iframe', utils.isIframe());
obj = utils.addPropertyIfNotNull(obj, 'journey_dismissals', journeyDismissals);
// obj = utils.addPropertyIfNotNull(obj, 'journey_dismissals', journeyDismissals);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Echoing suggestion to remove commented code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ope yeah, sorry this wasnt fully ready for review

Copy link

@gdeluna-branch gdeluna-branch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm, just some nits

@matter-code-review
Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@matter-code-review
Copy link

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@bredmond5 bredmond5 changed the title Inteng 22824 [patch] INTENG-22824: fix keyboard access to journeys and remove tabindex=-1 Jul 3, 2025
@bredmond5 bredmond5 merged commit 58bc816 into main Jul 3, 2025
6 checks passed
@bredmond5 bredmond5 deleted the inteng-22824 branch July 3, 2025 22:13
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