Skip to content

Commit 366031e

Browse files
authored
Fix carousel dot focus loss with VoiceOver activation (#127)
* fix: preserve carousel dot focus after VoiceOver activation * fix: avoid duplicate scroll snap lookup
1 parent 279a464 commit 366031e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/blocks/carousel/view.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,16 @@ store( 'rt-carousel/carousel', {
237237
viewport[ EMBLA_KEY ] = embla;
238238

239239
const updateState = () => {
240+
const scrollSnapList = embla.scrollSnapList();
240241
context.initialized = true;
241242
context.canScrollPrev = embla.canScrollPrev();
242243
context.canScrollNext = embla.canScrollNext();
243244
context.selectedIndex = embla.selectedScrollSnap();
244-
context.scrollSnaps = embla
245-
.scrollSnapList()
246-
.map( ( _, index ) => ( { index } ) );
245+
if ( context.scrollSnaps.length !== scrollSnapList.length ) {
246+
context.scrollSnaps = scrollSnapList.map( ( _, index ) => ( {
247+
index,
248+
} ) );
249+
}
247250
context.scrollProgress = embla.scrollProgress();
248251
context.slideCount = embla.slideNodes().length;
249252
};

0 commit comments

Comments
 (0)