Skip to content

[MWPW-171403][Preflight][Due diligence] Integrate full accessibility report in Preflight #3968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Jul 9, 2025

Conversation

skumar09
Copy link
Contributor

@skumar09 skumar09 commented Apr 14, 2025

  • Integrate Axe Core Accessibility Test into Preflight
  • Develop a custom accessibility-check function/method for rules that the axe-core library does not validate when analyzing or testing within the browser DOM.

Resolves: MWPW-171403

Test URLs:

Test Scenarios:

  1. Accessibility PASS
    URL: https://accessibility-preflight--milo--skumar09.aem.page/drafts/nala/preflight/media-light?martech=off
    image

  2. Accessibility FAIL ( Image - Alt Text is not correct)
    URL: https://accessibility-preflight--milo--skumar09.hlx.page/drafts/nala/preflight/media-image?martech=off
    image

  3. Accessibility FAIL ( Color Contrast Issue)
    URL: https://accessibility-preflight--milo--skumar09.aem.page/drafts/nala/preflight/media-small?martech=off
    image

@skumar09 skumar09 force-pushed the accessibility-preflight branch from 7cbba1d to 4502b2c Compare April 14, 2025 19:59
Copy link
Contributor

aem-code-sync bot commented Apr 14, 2025

@skumar09 skumar09 changed the title [MWPW-169392][Preflight][Due diligence] Integrate full accessibility report in Preflight [MWPW-171403][Preflight][Due diligence] Integrate full accessibility report in Preflight Apr 14, 2025
@skumar09 skumar09 added the do not merge PR should not be merged yet label Apr 14, 2025
Copy link
Contributor

This pull request is not passing all required checks. Please see this discussion for information on how to get all checks passing. Inconsistent checks can be manually retried. If a test absolutely can not pass for a good reason, please add a comment with an explanation to the PR.

// Filter DOM elements based on include/exclude
const elements = getFilteredElements(config.include, config.exclude);

if (!elements.length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this can be written in one line without curly braces


const violations = checkFunctions.flatMap((checkFn) => checkFn(elements, config));

return violations;
Copy link
Contributor

Choose a reason for hiding this comment

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

you can return violations directly without creating the constant

try {
// Filter DOM elements based on include/exclude
const elements = getFilteredElements(config.include, config.exclude);

Copy link
Contributor

Choose a reason for hiding this comment

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

this applies to multiple files - let's remove the empty lines between const declarations, const declaration / if, etc

// Skip this check if 'altText' isn't enabled in the config
if (!checks.includes('altText')) return [];
const violations = [];
const images = elements.filter((el) => el.tagName?.toLowerCase() === 'img');
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT:

Suggested change
const images = elements.filter((el) => el.tagName?.toLowerCase() === 'img');
const images = elements.filter((el) => el.tagName === 'IMG');

focusableElements.forEach((el) => {
const styles = window.getComputedStyle(el);
const hasVisibleOutline = styles.outlineStyle !== 'none' && parseFloat(styles.outlineWidth) > 0;
const hasBoxShadow = styles.boxShadow !== 'none' && styles.boxShadow !== '';
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT

Suggested change
const hasBoxShadow = styles.boxShadow !== 'none' && styles.boxShadow !== '';
const hasBoxShadow = styles.boxShadow !== 'none' && styles.boxShadow;

export function getFilteredElements(includeSelectors = ['body'], excludeSelectors = []) {
const includedElements = includeSelectors.flatMap((selector) => Array.from(document.querySelectorAll(`${selector}, ${selector} *`)));

if (excludeSelectors.length === 0) return includedElements;
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT:

Suggested change
if (excludeSelectors.length === 0) return includedElements;
if (!excludeSelectors.length) return includedElements;

Copy link
Contributor

@vhargrave vhargrave left a comment

Choose a reason for hiding this comment

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

I really like this implementation. It's effectively combining axe with some solid custom checks.
I’ve left a few comments on a few things that I've found.

In addition, adding unit tests would help ensure future changes don’t break anything, especially as preflight usage grows.

For the UI, the layout feels cramped for me when scrolling through multiple violations, as it only uses half the screen. Maybe we could consider moving violations directly under the failing accessibility test and using the full width to improve readability. What do you think?

image
image

const styles = window.getComputedStyle(el);
const isVisible = styles.display !== 'none' && styles.visibility !== 'hidden' && parseFloat(styles.opacity) > 0;
const hasText = el.textContent.trim().length > 0;
const tagWhitelist = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'a', 'button'];
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit concerned that certain elements might get missed here, such as a span tag, or list element <li><ul>, etc.
Have you considered instead filtering for elements that are visible and have direct text content? I think that could be more comprehensive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially included <span>, but later removed it to avoid false positives — similar to the concern with relying on direct text content. While direct text is more comprehensive, it can also give false positives. I've added <ul> and <li>, and will continue refining the tag list based on further exploration.
Please advise — WDYT?
In milo blocks typically i din't find standalone text inside <span> it’s usually nested within above whitelisted tags ( i might be missing the some cases ).

// Traverses the DOM to find the effective background color.
function getEffectiveBackgroundColor(element) {
let el = element;
while (el) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is clever, but I don't think this will work for important cases like a marquee. The background is not in the parents elements there.
https://main--cc--adobecom.aem.live/products/photoshop-lightroom

When I set the background to blue for example, the text background should recognize that the background is blue, but in this case it does not because the background is not in the direct parent chain.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vhargrave: You're right—this won't cover the above case, layered backgrounds from siblings, or positioned elements. I think we can create stories/Jiras for the same and work on follow-up PRs.

};

export const CUSTOM_CHECKS_CONFIG = {
checks: ['altText', 'color-contrast'],
Copy link
Contributor

Choose a reason for hiding this comment

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

Is is deliberate that you're not adding the keyboard checks as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is is deliberate that you're not adding the keyboard checks as well?

@vhargrave: Yes, it’s deliberate. Still exploring the use cases where axe-core doesn’t fully capture keyboard navigation issues when triggerred from browser/dom, will enable in subsequent pr's

@skumar09 skumar09 requested review from narcis-radu and zagi25 April 17, 2025 22:33
@skumar09
Copy link
Contributor Author

Hi @vhargrave @zagi25 @narcis-radu , please check the review updates/responses

Copy link
Contributor

github-actions bot commented May 2, 2025

This PR has not been updated recently and will be closed in 7 days if no action is taken. Please ensure all checks are passing, https://github.com/orgs/adobecom/discussions/997 provides instructions. If the PR is ready to be merged, please mark it with the "Ready for Stage" label.

@github-actions github-actions bot added the Stale label May 2, 2025
Copy link
Contributor

github-actions bot commented May 9, 2025

Closing this PR due to inactivity.

@github-actions github-actions bot closed this May 9, 2025
@skumar09 skumar09 reopened this May 29, 2025
@github-actions github-actions bot removed the Stale label May 30, 2025
@skumar09 skumar09 requested a review from robert-bogos June 23, 2025 02:58
@skumar09
Copy link
Contributor Author

Previously, we had labels on the images to display the alt text. I see that with these changes, they're no longer available. Was this intentional?

@robert-bogos : updated this one , merged/added earlier alt text feature into this pr accessibility tab

Copy link
Contributor

@robert-bogos robert-bogos left a comment

Choose a reason for hiding this comment

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

@skumar09 I see some unit tests are failing. Are they related to the code changes?

@skumar09
Copy link
Contributor Author

@skumar09 I see some unit tests are failing. Are they related to the code changes?

@robert-bogos : They are not related to code change, i have updated the branch with latest code base from stage, now they are passing, please review

@skumar09 skumar09 requested a review from robert-bogos June 23, 2025 17:14
@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jun 27, 2025

Skipped merging 3968: [MWPW-171403][Preflight][Due diligence] Integrate full accessibility report in Preflight due to failing or running checks

4 similar comments
@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jul 5, 2025

Skipped merging 3968: [MWPW-171403][Preflight][Due diligence] Integrate full accessibility report in Preflight due to failing or running checks

@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jul 6, 2025

Skipped merging 3968: [MWPW-171403][Preflight][Due diligence] Integrate full accessibility report in Preflight due to failing or running checks

@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jul 7, 2025

Skipped merging 3968: [MWPW-171403][Preflight][Due diligence] Integrate full accessibility report in Preflight due to failing or running checks

@milo-pr-merge
Copy link
Contributor

milo-pr-merge bot commented Jul 8, 2025

Skipped merging 3968: [MWPW-171403][Preflight][Due diligence] Integrate full accessibility report in Preflight due to failing or running checks

@milo-pr-merge milo-pr-merge bot merged commit 92544e7 into adobecom:stage Jul 9, 2025
13 checks passed
@milo-pr-merge milo-pr-merge bot mentioned this pull request Jul 9, 2025
thedoc31 pushed a commit that referenced this pull request Jul 9, 2025
…report in Preflight (#3968)

* initial commit

* update review comments

* update review comment-2

* update review comments-3

* add tags for color-contrast

* consider alt= as decorative images

* merge existing img alt feature into new accessibility tab

* adust the preflight-full-width css

* adust violation-column css bottom padding

* updated the tags

* update the tags

* rm color-contrast

* remove console log

* include wcag22a and wcag22aa support

* comment update

---------

Co-authored-by: Santoshkumar Sharanappa Nateekar <[email protected]>
Co-authored-by: Santoshkumar Sharanappa Nateekar <[email protected]>
ajullal pushed a commit to ajullal/milo that referenced this pull request Jul 9, 2025
…report in Preflight (adobecom#3968)

* initial commit

* update review comments

* update review comment-2

* update review comments-3

* add tags for color-contrast

* consider alt= as decorative images

* merge existing img alt feature into new accessibility tab

* adust the preflight-full-width css

* adust violation-column css bottom padding

* updated the tags

* update the tags

* rm color-contrast

* remove console log

* include wcag22a and wcag22aa support

* comment update

---------

Co-authored-by: Santoshkumar Sharanappa Nateekar <[email protected]>
Co-authored-by: Santoshkumar Sharanappa Nateekar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants