@@ -11,10 +11,6 @@ import { BaseAccordionPanel } from './BaseAccordionPanel.js';
1111
1212import { RovingTabindexController } from '@patternfly/pfe-core/controllers/roving-tabindex-controller.js' ;
1313
14- import style from './BaseAccordion.css' ;
15-
16- const CSS_TIMING_UNITS_RE = / ^ [ 0 - 9 . ] + (?< unit > [ a - z A - Z ] + ) / g;
17-
1814export class AccordionExpandEvent extends ComposedEvent {
1915 constructor (
2016 public toggle : BaseAccordionHeader ,
@@ -34,7 +30,7 @@ export class AccordionCollapseEvent extends ComposedEvent {
3430}
3531
3632export abstract class BaseAccordion extends LitElement {
37- static readonly styles = [ style ] ;
33+ static readonly styles = [ ] ;
3834
3935 static isAccordion ( target : EventTarget | null ) : target is BaseAccordion {
4036 return target instanceof BaseAccordion ;
@@ -104,10 +100,6 @@ export abstract class BaseAccordion extends LitElement {
104100
105101 #logger = new Logger ( this ) ;
106102
107- #styles = getComputedStyle ( this ) ;
108-
109- #transitionDuration = this . #getAnimationDuration( ) ;
110-
111103 // actually is read in #init, by the `||=` operator
112104 #initialized = false ;
113105
@@ -158,11 +150,11 @@ export abstract class BaseAccordion extends LitElement {
158150 this . #initialized ||= ! ! await this . updateComplete ;
159151 this . #headerIndex. initItems ( this . headers ) ;
160152 // Event listener to the accordion header after the accordion has been initialized to add the roving tabindex
161- this . addEventListener ( 'focusin' , this . #updateActiveHeader as EventListener ) ;
153+ this . addEventListener ( 'focusin' , this . #updateActiveHeader) ;
162154 this . updateAccessibility ( ) ;
163155 }
164156
165- #updateActiveHeader( event : FocusEvent ) {
157+ #updateActiveHeader( ) {
166158 if ( this . #activeHeader) {
167159 this . #headerIndex. updateActiveItem ( this . #activeHeader) ;
168160 }
@@ -184,15 +176,9 @@ export abstract class BaseAccordion extends LitElement {
184176 header . expanded = true ;
185177 }
186178
187- async #expandPanel( panel : BaseAccordionPanel ) {
179+ #expandPanel( panel : BaseAccordionPanel ) {
188180 panel . expanded = true ;
189181 panel . hidden = false ;
190-
191- await panel . updateComplete ;
192-
193- const rect = panel . getBoundingClientRect ( ) ;
194-
195- this . #animate( panel , 0 , rect . height ) ;
196182 }
197183
198184 async #collapseHeader( header : BaseAccordionHeader , index = this . #getIndex( header ) ) {
@@ -210,66 +196,12 @@ export abstract class BaseAccordion extends LitElement {
210196 return ;
211197 }
212198
213- const rect = panel . getBoundingClientRect ( ) ;
214-
215199 panel . expanded = false ;
216200 panel . hidden = true ;
217-
218- this . #animate( panel , rect . height , 0 ) ;
219- await panel . updateComplete ;
220- }
221-
222- #getAnimationDuration( ) : number {
223- if ( 'computedStyleMap' in this ) {
224- // @ts -expect-error: https://caniuse.com/?search=computedStyleMap
225- return this . computedStyleMap ( ) . get ( 'transition-duration' ) ?. to ( 'ms' ) . value ;
226- } else {
227- const { transitionDuration } = this . #styles;
228-
229- const groups = CSS_TIMING_UNITS_RE . exec ( transitionDuration ) ?. groups ;
230-
231- if ( ! groups ) {
232- return 0 ;
233- }
234-
235- const parsed = parseFloat ( transitionDuration ) ;
236-
237- if ( groups . unit === 's' ) {
238- return parsed * 1000 ;
239- } else {
240- return parsed ;
241- }
242- }
243- }
244-
245- async #animate( panel : BaseAccordionPanel , start : number , end : number ) {
246- if ( panel ) {
247- const header = panel . previousElementSibling ;
248-
249- const transitionDuration = this . #getAnimationDuration( ) ;
250- if ( transitionDuration ) {
251- this . #transitionDuration = transitionDuration ;
252- }
253-
254- const duration = this . #transitionDuration ?? 0 ;
255-
256- header ?. classList . add ( 'animating' ) ;
257- panel . classList . add ( 'animating' ) ;
258-
259- const animation = panel . animate ( { height : [ `${ start } px` , `${ end } px` ] } , { duration } ) ;
260- animation . play ( ) ;
261- await animation . finished ;
262-
263- header ?. classList . remove ( 'animating' ) ;
264- panel . classList . remove ( 'animating' ) ;
265-
266- panel . style . removeProperty ( 'height' ) ;
267- panel . hidden = ! panel . expanded ;
268- }
269201 }
270202
271203 #onChange( event : AccordionHeaderChangeEvent ) {
272- if ( BaseAccordion . #isAccordionChangeEvent( event ) && ! this . classList . contains ( 'animating' ) ) {
204+ if ( BaseAccordion . #isAccordionChangeEvent( event ) ) {
273205 const index = this . #getIndex( event . target ) ;
274206 if ( event . expanded ) {
275207 this . expand ( index , event . accordion ) ;
0 commit comments