Splidejs / splide

Splide is a lightweight, flexible and accessible slider/carousel written in TypeScript. No dependencies, no Lighthouse errors.
https://splidejs.com
MIT License
4.89k stars 424 forks source link

Destroy does not remove `tabindex="-1"` from all items causing an accessibility issue #1134

Open okadots opened 1 year ago

okadots commented 1 year ago

Checks

Version

4.1.4

Description

I am destroying the slide at 768px > browsers. The slider is destroyed successfully, but the tabindex="-1" is not removed from the descendent links in all of the elements. In my case, all of the individual elements have links inside. Because of this, a user cannot tab through the items. destroy also does not remove the IDs that are added to each slide, this however, does not affect the user's ability to tab through elements, so it is not an accessibility issue.

Below are my options.

        perPage: 1, 
        arrows: false,
        gap: '1rem', 
        focus: 0,
        mediaQuery: 'min',
        breakpoints: {
            0: {
                perPage: 1,
                arrows: false,
            },
            768: {
                destroy: 'completely'
            }
        }

Screenshot of markup showing tabindex and ID. splide-tabindex

Reproduction Link

No response

Steps to Reproduce

  1. Load page in browser wider than 768px
  2. Try to tab through each element.

Expected Behaviour

Expect that the tabindex="-1" would be removed as part of the destroy function.

azuredusk10 commented 10 months ago

I'm experiencing the same bug.

As a workaround, in the same breakpoint where I call destroy, I'm setting the perPage value greater than or equal to the number of slides.

E.g.: A slider with 6 slides which is only a slider on tablet breakpoints and below:

document.addEventListener( 'DOMContentLoaded', function(){   
  new Splide( '.splide', {
    mediaQuery: 'min',
        perPage: 1,
        arrows: false,
        breakpoints: {
          768: {
            perPage: 2
          },
          992: {
            perPage: 6,
            destroy: true
          }
    }
  }).mount();
} );

On desktop, Splide now thinks it's showing all the slides at once, so it removes tabindex="-1" from each slide, even though the actual slider is disabled.