From 7178c297cf7594a3e5b630ccfee1c5f46964bcde Mon Sep 17 00:00:00 2001 From: IgnacioBecerra Date: Mon, 8 Feb 2021 10:30:56 -0800 Subject: [PATCH] Revert "Merge branch 'carousel-focus-fix'" This reverts commit d3523ab0842bab1b5c227bc7dc9d74d492b63320, reversing changes made to 58ec2362f59fad4af8588ba7d01565419d31baff. --- .../src/components/carousel/carousel.ts | 38 +------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/packages/web-components/src/components/carousel/carousel.ts b/packages/web-components/src/components/carousel/carousel.ts index bb04b5ec86e..5c22683e645 100644 --- a/packages/web-components/src/components/carousel/carousel.ts +++ b/packages/web-components/src/components/carousel/carousel.ts @@ -13,9 +13,6 @@ import ddsSettings from '@carbon/ibmdotcom-utilities/es/utilities/settings/setti import ifNonNull from 'carbon-web-components/es/globals/directives/if-non-null.js'; import CaretLeft20 from 'carbon-web-components/es/icons/caret--left/20.js'; import CaretRight20 from 'carbon-web-components/es/icons/caret--right/20.js'; -import HostListener from 'carbon-web-components/es/globals/decorators/host-listener'; -import HostListenerMixin from 'carbon-web-components/es/globals/mixins/host-listener'; -import DDSCard from '../card/card'; import styles from './carousel.scss'; const { prefix } = settings; @@ -29,7 +26,7 @@ const { stablePrefix: ddsPrefix } = ddsSettings; * @csspart next-button The button to go to the next page. */ @customElement(`${ddsPrefix}-carousel`) -class DDSCarousel extends HostListenerMixin(LitElement) { +class DDSCarousel extends LitElement { /** * The scrolling contents node. */ @@ -114,39 +111,6 @@ class DDSCarousel extends HostListenerMixin(LitElement) { } } - /** - * Handles card focus throughout pages. - * - * @param event The event. - */ - @HostListener('shadowRoot:focusin') - // @ts-ignore: The decorator refers to this method but TS thinks this method is not referred to - private _handleFocus = async ({ target, relatedTarget }: FocusEvent) => { - const currentContains = target !== this && this.contains(target as DDSCard); - const oldNotContains = target !== this && !this.contains(relatedTarget as DDSCard); - const currentCardIndex = Array.from(this.children).indexOf(target as HTMLElement); - - // keep current page if tabbing back into the carousel after previously moving pages - if (currentContains && oldNotContains && currentCardIndex === 0) { - (this.children[this.start] as HTMLElement).focus(); - return; - } - - if (currentContains) { - // going forwards, change page depending on card index - if (currentCardIndex >= this.start + this.pageSize) { - const nextStart = currentCardIndex - (currentCardIndex % this.pageSize); - const pageOffset = this.start % this.pageSize; - - this.start = nextStart + pageOffset; - - // going backwards, change page depending on card index - } else if (currentCardIndex < this.start) { - this.start = Math.max(currentCardIndex + 1 - this.pageSize, 0); - } - } - }; - /** * Handles `click` event on the next button. */