Skip to content
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

MWPW-162026 [Milo][Sev2][Catalog] Group of checkboxes is missing FIELDSET … #3518

Merged
merged 9 commits into from
Jan 28, 2025

Conversation

bozojovicic
Copy link
Contributor

@bozojovicic bozojovicic commented Jan 21, 2025

… element - filter checkboxes

A11Y fix - In merch-sidenav-checkbox-group For Type Desktop/Mobile/Web checkbox group ARIA group/labelledby technique applied to announce the grouping as a part of the checkboxes. This does not work if we have aria-labelledby="elementId" and #elementId is in shadow DOM so I had to create new hidden DIV, outside shadow DOM, which will have that ID and contain the text "Types".

Test page : /products/catalog?milolibs=mwpw162026a11y--milo--bozojovicic

Resolves: MWPW-162026

Test URLs:

Copy link
Contributor

aem-code-sync bot commented Jan 21, 2025

Page Scores Audits Google
📱 /drafts/bozo/price-cta?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ /drafts/bozo/price-cta?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.49%. Comparing base (0a9e222) to head (b8541c7).
Report is 5 commits behind head on stage.

Additional details and impacted files
@@           Coverage Diff           @@
##            stage    #3518   +/-   ##
=======================================
  Coverage   96.49%   96.49%           
=======================================
  Files         260      260           
  Lines       60763    60776   +13     
=======================================
+ Hits        58632    58647   +15     
+ Misses       2131     2129    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

const groupIdEl = createTag('div', { class: 'invisible-and-shrank', id });
groupIdEl.textContent = this.sidenavCheckboxTitle;
this.append(groupIdEl);
this.querySelectorAll('sp-checkbox').forEach((checkboxEl) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

i am not sure i like the idea of merch-sidenav-checkbox-group being bound to sp-checkbox.
can't we add this 'role' attribute when we create those 'sp-checkboxes'? https://github.com/adobecom/cc/blob/stage/creativecloud/blocks/sidenav/sidenav.js#L79
I understand it means we need to rely on some stable id, so not sure if its better or not. maybe a bit less confusing for devs

Copy link
Contributor

Choose a reason for hiding this comment

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

and same with groupIdEl element, it could be probably created by sidenav block
@npeltier @yesil wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

I know the JIRA recommends a few options, but can we try the OOTB SWC approach with sp-field-group
https://opensource.adobe.com/spectrum-web-components/components/field-group/

image

Before implementing this solution, the accessibility tool can be run against checkboxes in the SWC documentation

image
if it doesn't complain we can follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yesil I tried your idea directly on catalog page
Screenshot 2025-01-27 at 12 48 10
it doesn't work. :( Screen reader ignores the word "Types" although it is there twice, once in element "label" and once in attribute "label"

@3ch023 we had this in CC code before but then it was requested to move to Milo

@npeltier I can move that "types" element from shadow to light dom but again I need to iterate through checkboxes to set attributes 'aria-labelledby', and that is where Mariia complains about

So, option A : I do it in CC code in sidenav.js, I move the H3 element from shadow to light dom
option B : I do the same thing in milo code
For both options one reviewer will not be happy.

@3ch023 I could also try to iterate through direct children of merch-sidenav-checkbox-group, without bounding to sp-checkbox, in that case it would be OK to do it in Milo code, right? I think that is the only solution where everyone is happy. Let me try.

Copy link
Contributor

@3ch023 3ch023 Jan 27, 2025

Choose a reason for hiding this comment

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

I am fine with any solution you pick, its just the current one looked 'hacked' to me. and i wonder if there is a better way. (first sidenav block creates elements, then checkout-group modifies it's children and itself)
I've read @npeltier new suggestion a few times and didn't understand it still

Copy link
Contributor

@npeltier npeltier left a comment

Choose a reason for hiding this comment

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

thanks @3ch023

looked at it again. I guess @bozojovicic it would be better to pull out the group headings of the shadow DOM to the light DOM and you should be good.
We should not duplicate content and hack around this.

const groupIdEl = createTag('div', { class: 'invisible-and-shrank', id });
groupIdEl.textContent = this.sidenavCheckboxTitle;
this.append(groupIdEl);
this.querySelectorAll('sp-checkbox').forEach((checkboxEl) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know the JIRA recommends a few options, but can we try the OOTB SWC approach with sp-field-group
https://opensource.adobe.com/spectrum-web-components/components/field-group/

image

Before implementing this solution, the accessibility tool can be run against checkboxes in the SWC documentation

image
if it doesn't complain we can follow.

@bozojovicic bozojovicic requested a review from mirafedas January 27, 2025 14:08
@bozojovicic
Copy link
Contributor Author

@yesil @npeltier @3ch023 I think finally here is the solution which covers it all and works.
https://stage--cc--adobecom.hlx.page/products/catalog?milolibs=mwpw162026a11y--milo--bozojovicic

  • merch-sidenav-checkbox-group is not bound to sp-checkbox element, it adds needed aria attributes to all direct children
  • title element is not duplicated, I moved it from shadow dom to light dom
  • CSS for that title I had to move to global.css.js, @mirafedas had a suggestion to move it to CC code but I don't like the idea to have one more PR for this

Copy link
Contributor

@3ch023 3ch023 left a comment

Choose a reason for hiding this comment

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

works for me.
if/when we move sidenav block to Milo we probably should move 'sidenav-checkbox-group-title' creation to sidenav block. and keep merch-sidenav-checkbox-group more simple

i think its about generat expectation that web component will create shadow dom, but an outer actor creates the light dom children

Copy link
Contributor

@npeltier npeltier left a comment

Choose a reason for hiding this comment

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

thanks a lot @bozojovicic looks good to me!

libs/features/mas/src/global.css.js Outdated Show resolved Hide resolved
@Roycethan Roycethan added verified PR has been E2E tested by a reviewer Ready for Stage labels Jan 27, 2025
@milo-pr-merge milo-pr-merge bot merged commit 05c029e into adobecom:stage Jan 28, 2025
24 checks passed
@milo-pr-merge milo-pr-merge bot mentioned this pull request Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commerce Ready for Stage verified PR has been E2E tested by a reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants