question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Carousel implementation does not pass WCAG2a using Axe tests in Cypress

See original GitHub issue
  • pure-react-carousel version: ^1.27.5
  • react version: ^16.8
  • browser used: Chrome
  • node version: v12.18.4

Relevant code or config:

            <div
                data-testid="spotlights"
                style={{ height: '100%', position: 'relative' }}
                role="region"
                aria-label="Spotlights carousel"
            >
                <CarouselProvider
                    visibleSlides={1}
                    totalSlides={totalSlides}
                    step={1}
                    naturalSlideWidth={1967}
                    naturalSlideHeight={721}
                    isPlaying={!account}
                    interval={10000}
                    style={{ height: '100%' }}
                >
                    {totalSlides > 1 && (
                        <div
                            style={{
                                width: 36,
                                height: '100%',
                                position: 'absolute',
                                top: 4,
                                left: 4,
                                zIndex: 101,
                            }}
                        >
                            <ButtonBack>
                                <ChevronLeftIcon />
                            </ButtonBack>
                        </div>
                    )}
                    {totalSlides > 1 && (
                        <div
                            style={{
                                width: 36,
                                height: '100%',
                                position: 'absolute',
                                top: 4,
                                right: 0,
                                zIndex: 101,
                            }}
                        >
                            <ButtonNext>
                                <ChevronRightIcon />
                            </ButtonNext>
                        </div>
                    )}
                    {totalSlides > 1 && (
                        <div
                            style={{
                                width: 36,
                                position: 'absolute',
                                top: 4,
                                left: 32,
                                zIndex: 101,
                            }}
                        >
                            <ButtonPlay childrenPlaying={<PauseIcon />} childrenPaused={<PlayArrowIcon />} />
                        </div>
                    )}
                    {totalSlides > 1 && (
                        <div
                            style={{
                                width: 200,
                                marginLeft: -100,
                                position: 'absolute',
                                top: 0,
                                left: '50%',
                                zIndex: 101,
                                textAlign: 'center',
                            }}
                        >
                            <DotGroup />
                        </div>
                    )}
                    <div
                        style={{
                            zIndex: 99,
                        }}
                    >
                        <Slider>
                            {slides.map((item, index) => {
                                return (
                                    <Slide index={item.index} key={index}>
                                        <a href={item.link} aria-label={item.aria}>
                                            <Image
                                                src={item.src}
                                                alt={item.alt}
                                                style={{ width: '100%' }}
                                                aria-label={item.aria}
                                            />
                                        </a>
                                    </Slide>
                                );
                            })}
                        </Slider>
                    </div>
                </CarouselProvider>
            </div>

What you did:

Running Axe in Cypress tests for WCAG compliance.

What happened:

failureSummary: "Fix any of the following:↵  aria-label attribute does not exist or is empty↵  aria-labelledby attribute does not exist, references elements that do not exist or references elements that are empty↵  Element has no title attribute or the title attribute is empty"
html: "<div class="horizontalSlider___281Ls carousel__slider carousel__slider--horizontal" aria-live="polite" tabindex="0" role="listbox">"
impact: "serious"
failureSummary: "Fix all of the following:↵  List element has direct children that are not allowed inside <li> elements"
html: "<ul class="sliderTray___-vHFQ sliderAnimation___300FY carousel__slider-tray carousel__slider-tray--horizontal" style="width: 400%; transform: translateX(0%) translateX(0px); flex-direction: row;">"
impact: "serious"

Problem description:

Does not pass WCAG2a tests at the moment.

Suggested solution:

Fixes are explained in the errors above.

Can you help us fix this issue by submitting a pull request?

TBH - Have never tried - but happy to when I get some time.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
CatchGuscommented, Dec 2, 2020

The first violation can be solved by passing your own aria-label prop to Slider

The second violation is “List element has direct children with a role that is not allowed: option”. Apparently putting a role of option on an li element is a no no. This can be solved by changing the ul and li tags to a different element.

<Slider aria-label="My accessible name" trayTag="div">
   <Slide tag="div">...<Slide>
</Slider>

Should probably be fixed up the code though… Also this is not a Cypress only issue, I also saw these violations surfaced in our Storybook.

0reactions
stale[bot]commented, Jun 11, 2021

This issue has been automatically closed becuase it has not had recent activity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · component-driven/cypress-axe - GitHub
Resolved path for axe-core/axe.min.js is incorrect if the Cypress Config is in a sub-directory when using Cypress v10+.
Read more >
How to test for accessibility with Cypress - Deque Systems
In this article, we're going to discuss how to: Create test cases in Cypress. Integrate and use axe to check for accessibility violations....
Read more >
Implement A Test That Finds A Particular Slide In A Carousel
This test shows how to check if an element is visible, and if not, click on the "Next" button in the carousel. The...
Read more >
A Complete Guide To Accessibility Tooling
This time we look into different kinds of tools to help you streamline your accessibility testing process. Don't miss the next one.
Read more >
How to test carousel with image in Cypress? - Stack Overflow
I would like to check whether the carousel is displayed on the page and whether the active image has the correct class. I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found