diff --git a/src/modules/a11y/a11y.mjs b/src/modules/a11y/a11y.mjs index 19b9aea0e..97ead239d 100644 --- a/src/modules/a11y/a11y.mjs +++ b/src/modules/a11y/a11y.mjs @@ -18,6 +18,7 @@ export default function A11y({ swiper, extendParams, on }) { itemRoleDescriptionMessage: null, slideRole: 'group', id: null, + scrollOnFocus: true }, }); @@ -236,7 +237,7 @@ export default function A11y({ swiper, extendParams, on }) { }; const handleFocus = (e) => { - if (swiper.a11y.clicked) return; + if (swiper.a11y.clicked || !swiper.params.a11y.scrollOnFocus) return; if (new Date().getTime() - visibilityChangedTimestamp < 100) return; const slideEl = e.target.closest(`.${swiper.params.slideClass}, swiper-slide`); diff --git a/src/types/modules/a11y.d.ts b/src/types/modules/a11y.d.ts index 134f158ff..67cb64a57 100644 --- a/src/types/modules/a11y.d.ts +++ b/src/types/modules/a11y.d.ts @@ -93,4 +93,11 @@ export interface A11yOptions { * @default null */ id?: string | number | null; + + /** + * Enables scrolling to the slide that has been focused + * + * @default true + */ + scrollOnFocus?: boolean; }