From 1b301dae580dc4619cd6c5c75027b3a8714de45d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 15 Apr 2024 16:01:37 +0200 Subject: [PATCH] MOBILE-4565 a11y: Do not let the user focus on elements in movement --- src/core/components/swipe-slides/swipe-slides.html | 2 +- src/core/components/swipe-slides/swipe-slides.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/components/swipe-slides/swipe-slides.html b/src/core/components/swipe-slides/swipe-slides.html index bcfc05ac8..490a6f3e3 100644 --- a/src/core/components/swipe-slides/swipe-slides.html +++ b/src/core/components/swipe-slides/swipe-slides.html @@ -1,4 +1,4 @@ - + diff --git a/src/core/components/swipe-slides/swipe-slides.ts b/src/core/components/swipe-slides/swipe-slides.ts index fa3864c38..360968d83 100644 --- a/src/core/components/swipe-slides/swipe-slides.ts +++ b/src/core/components/swipe-slides/swipe-slides.ts @@ -72,7 +72,7 @@ export class CoreSwipeSlidesComponent implements OnChanges, OnDe protected hostElement: HTMLElement; protected unsubscribe?: () => void; protected resizeListener: CoreEventObserver; - protected activeSlideIndexes: number[] = []; + protected activeSlideIndex?: number; protected onReadyPromise = new CorePromisedValue(); constructor( @@ -112,7 +112,7 @@ export class CoreSwipeSlidesComponent implements OnChanges, OnDe * @returns Whether the slide is active. */ isActive(index: number): boolean { - return this.activeSlideIndexes.includes(index); + return this.activeSlideIndex === index; } /** @@ -153,7 +153,7 @@ export class CoreSwipeSlidesComponent implements OnChanges, OnDe item: items[initialIndex], }; - this.activeSlideIndexes = [initialIndex]; + this.activeSlideIndex = initialIndex; this.manager.setSelectedItem(items[initialIndex]); this.onWillChange.emit(initialItemData); @@ -268,7 +268,7 @@ export class CoreSwipeSlidesComponent implements OnChanges, OnDe return; } - this.activeSlideIndexes.push(currentItemData.index); + this.activeSlideIndex = undefined; this.manager?.setSelectedItem(currentItemData.item); this.onWillChange.emit(currentItemData); @@ -283,12 +283,12 @@ export class CoreSwipeSlidesComponent implements OnChanges, OnDe async slideDidChange(): Promise { const currentItemData = await this.getCurrentSlideItemData(); if (!currentItemData) { - this.activeSlideIndexes = []; + this.activeSlideIndex = undefined; return; } - this.activeSlideIndexes = [currentItemData.index]; + this.activeSlideIndex = currentItemData.index; this.onDidChange.emit(currentItemData);