Skip to content

Commit f4f7da0

Browse files
authored
feat(a11y): added new prop for a11y module - scrollOnFocus (#7632)
* added new prop for a11y module - scrollOnFocus * added props to handleFocus
1 parent 1bb2746 commit f4f7da0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/modules/a11y/a11y.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default function A11y({ swiper, extendParams, on }) {
1818
itemRoleDescriptionMessage: null,
1919
slideRole: 'group',
2020
id: null,
21+
scrollOnFocus: true
2122
},
2223
});
2324

@@ -236,7 +237,7 @@ export default function A11y({ swiper, extendParams, on }) {
236237
};
237238

238239
const handleFocus = (e) => {
239-
if (swiper.a11y.clicked) return;
240+
if (swiper.a11y.clicked || !swiper.params.a11y.scrollOnFocus) return;
240241
if (new Date().getTime() - visibilityChangedTimestamp < 100) return;
241242

242243
const slideEl = e.target.closest(`.${swiper.params.slideClass}, swiper-slide`);

src/types/modules/a11y.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,11 @@ export interface A11yOptions {
9393
* @default null
9494
*/
9595
id?: string | number | null;
96+
97+
/**
98+
* Enables scrolling to the slide that has been focused
99+
*
100+
* @default true
101+
*/
102+
scrollOnFocus?: boolean;
96103
}

0 commit comments

Comments
 (0)