Bladeren bron

Bug Fix: Prevent Windows narrator from reading unnecessary "selection" texts.

NaotoshiFujita 3 jaren geleden
bovenliggende
commit
15fe8a58ea

File diff suppressed because it is too large
+ 0 - 0
dist/css/splide-core.min.css


File diff suppressed because it is too large
+ 0 - 0
dist/css/splide.min.css


File diff suppressed because it is too large
+ 0 - 0
dist/css/themes/splide-default.min.css


File diff suppressed because it is too large
+ 0 - 0
dist/css/themes/splide-sea-green.min.css


File diff suppressed because it is too large
+ 0 - 0
dist/css/themes/splide-skyblue.min.css


+ 10 - 6
dist/js/splide.js

@@ -856,10 +856,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
     }
 
     function listen() {
-      bind(slide, "click keydown", function (e) {
-        emit(e.type === "click" ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, self, e);
-      });
+      bind(slide, "click", apply(emit, EVENT_CLICK, self));
+      bind(slide, "keydown", apply(emit, EVENT_SLIDE_KEYDOWN, self));
       on([EVENT_REFRESH, EVENT_REPOSITIONED, EVENT_SHIFTED, EVENT_MOVED, EVENT_SCROLLED], update);
+      on([EVENT_REFRESH, EVENT_REPOSITIONED, EVENT_MOVED, EVENT_SCROLLED], updateAria);
       on(EVENT_NAVIGATION_MOUNTED, initNavigation);
 
       if (updateOnMove) {
@@ -913,10 +913,9 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
       var hidden = !visible && (!isActive() || isClone);
 
       if (document.activeElement === slide && hidden) {
-        nextTick(forwardFocus);
+        nextTick(keepFocus);
       }
 
-      setAttribute(slide, ARIA_HIDDEN, hidden || "");
       setAttribute(slide, TAB_INDEX, !hidden && options.slideFocus ? 0 : "");
       setAttribute(queryAll(slide, options.focusableNodes || ""), TAB_INDEX, hidden ? -1 : "");
 
@@ -926,7 +925,12 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
       }
     }
 
-    function forwardFocus() {
+    function updateAria() {
+      var hidden = !isVisible() && (!isActive() || isClone);
+      setAttribute(slide, ARIA_HIDDEN, hidden || "");
+    }
+
+    function keepFocus() {
       var Slide2 = Components.Slides.getAt(Splide2.index);
 
       if (Slide2) {

+ 1 - 1
src/css/core/object/objects/slide.scss

@@ -12,7 +12,7 @@
       vertical-align: bottom;
     }
 
-    &.is-active {
+    &:not([aria-hidden]) {
       display: block;
     }
   }

+ 16 - 7
src/js/components/Slides/Slide.ts

@@ -36,7 +36,7 @@ import { EventInterface } from '../../constructors';
 import { Splide } from '../../core/Splide/Splide';
 import { BaseComponent } from '../../types';
 import {
-  abs,
+  abs, apply,
   ceil,
   child,
   floor,
@@ -117,11 +117,11 @@ export function Slide( Splide: Splide, index: number, slideIndex: number, slide:
    * Listens to some events.
    */
   function listen(): void {
-    bind( slide, 'click keydown', e => {
-      emit( e.type === 'click' ? EVENT_CLICK : EVENT_SLIDE_KEYDOWN, self, e );
-    } );
+    bind( slide, 'click', apply( emit, EVENT_CLICK, self ) );
+    bind( slide, 'keydown', apply( emit, EVENT_SLIDE_KEYDOWN, self ) );
 
     on( [ EVENT_REFRESH, EVENT_REPOSITIONED, EVENT_SHIFTED, EVENT_MOVED, EVENT_SCROLLED ], update );
+    on( [ EVENT_REFRESH, EVENT_REPOSITIONED, EVENT_MOVED, EVENT_SCROLLED ], updateAria );
     on( EVENT_NAVIGATION_MOUNTED, initNavigation );
 
     if ( updateOnMove ) {
@@ -200,10 +200,9 @@ export function Slide( Splide: Splide, index: number, slideIndex: number, slide:
     const hidden = ! visible && ( ! isActive() || isClone );
 
     if ( document.activeElement === slide && hidden ) {
-      nextTick( forwardFocus );
+      nextTick( keepFocus );
     }
 
-    setAttribute( slide, ARIA_HIDDEN, hidden || '' );
     setAttribute( slide, TAB_INDEX, ! hidden && options.slideFocus ? 0 : '' );
     setAttribute( queryAll( slide, options.focusableNodes || '' ), TAB_INDEX, hidden ? -1 : '' );
 
@@ -213,11 +212,21 @@ export function Slide( Splide: Splide, index: number, slideIndex: number, slide:
     }
   }
 
+  /**
+   * Updates aria attributes.
+   *
+   * @todo
+   */
+  function updateAria(): void {
+    const hidden = ! isVisible() && ( ! isActive() || isClone );
+    setAttribute( slide, ARIA_HIDDEN, hidden || '' );
+  }
+
   /**
    * Forwards the focus to the active element.
    * Avoid losing focus from the slider when the focused slide gets hidden by slider move.
    */
-  function forwardFocus(): void {
+  function keepFocus(): void {
     const Slide = Components.Slides.getAt( Splide.index );
 
     if ( Slide ) {

Some files were not shown because too many files changed in this diff