- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.4k
fix(accordion-group): skip initial animation #30729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            ShaneK
  wants to merge
  10
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
FW-6730
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
      
        
          +237
        
        
          −14
        
        
          
        
      
    
  
  
     Open
                    Changes from 6 commits
      Commits
    
    
            Show all changes
          
          
            10 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      58c2a8a
              
                fix(accordion): skip initial animation
              
              
                ShaneK 761d06f
              
                fix(accordion-group): fixing animation in react
              
              
                ShaneK 1a1dcda
              
                Merge branch 'main' of github.com:ionic-team/ionic-framework into FW-…
              
              
                ShaneK 2095f2f
              
                fix(accordion): animating open if the first opening is done by the user
              
              
                ShaneK 63f32a5
              
                fix(accordion-group): skipping initial arrow animation
              
              
                ShaneK cc125e6
              
                chore(accordion): adding comment explaining when we want to skip the …
              
              
                ShaneK 90ebfba
              
                fix(accordion): re-rendering after intitial load to reset animation s…
              
              
                ShaneK e345efd
              
                fix(accordion): defaulting to skip initial animation until first render
              
              
                ShaneK f84c484
              
                fix(accordion): moving to state-based re-rendering instead of calling…
              
              
                ShaneK 0ce05dc
              
                fix(accordion): trying to prevent animation based on interaction rath…
              
              
                ShaneK File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
          Some comments aren't visible on the classic Files Changed page.
        
There are no files selected for viewing
        
          
          
            1 change: 1 addition & 0 deletions
          
          1 
        
  core/src/components/accordion-group/accordion-group-interface.ts
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import { newSpecPage } from '@stencil/core/testing'; | ||
|  | ||
| import type { AccordionGroupChangeEventDetail } from '../../accordion-group/accordion-group-interface'; | ||
| import { AccordionGroup } from '../../accordion-group/accordion-group'; | ||
| import { Item } from '../../item/item'; | ||
| import { Accordion } from '../accordion'; | ||
|  | @@ -200,6 +201,110 @@ it('should set default values if not provided', async () => { | |
| expect(accordion.classList.contains('accordion-collapsed')).toEqual(false); | ||
| }); | ||
|  | ||
| it('should not animate when initial value is set before load', async () => { | ||
| const page = await newSpecPage({ | ||
| components: [Item, Accordion, AccordionGroup], | ||
| }); | ||
|  | ||
| const accordionGroup = page.doc.createElement('ion-accordion-group'); | ||
| accordionGroup.innerHTML = ` | ||
| <ion-accordion value="first"> | ||
| <ion-item slot="header">Label</ion-item> | ||
| <div slot="content">Content</div> | ||
| </ion-accordion> | ||
| <ion-accordion value="second"> | ||
| <ion-item slot="header">Label</ion-item> | ||
| <div slot="content">Content</div> | ||
| </ion-accordion> | ||
| `; | ||
|  | ||
| const details: AccordionGroupChangeEventDetail[] = []; | ||
| accordionGroup.addEventListener('ionValueChange', (event: CustomEvent<AccordionGroupChangeEventDetail>) => { | ||
| details.push(event.detail); | ||
| }); | ||
|  | ||
| accordionGroup.value = 'first'; | ||
| page.body.appendChild(accordionGroup); | ||
|  | ||
| await page.waitForChanges(); | ||
|  | ||
| expect(details[0]?.initial).toBe(true); | ||
|  | ||
| const firstAccordion = accordionGroup.querySelector('ion-accordion[value="first"]')!; | ||
|  | ||
| expect(firstAccordion.classList.contains('accordion-expanded')).toEqual(true); | ||
| expect(firstAccordion.classList.contains('accordion-expanding')).toEqual(false); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't realize that spec tests capture these kinds of classes. I would have expected it to be false all the time since  | ||
| expect(firstAccordion.classList.contains('accordion-animated')).toEqual(false); | ||
| }); | ||
|  | ||
| it('should not animate when initial value is set after load', async () => { | ||
| const page = await newSpecPage({ | ||
| components: [Item, Accordion, AccordionGroup], | ||
| }); | ||
|  | ||
| const accordionGroup = page.doc.createElement('ion-accordion-group'); | ||
| accordionGroup.innerHTML = ` | ||
| <ion-accordion value="first"> | ||
| <ion-item slot="header">Label</ion-item> | ||
| <div slot="content">Content</div> | ||
| </ion-accordion> | ||
| <ion-accordion value="second"> | ||
| <ion-item slot="header">Label</ion-item> | ||
| <div slot="content">Content</div> | ||
| </ion-accordion> | ||
| `; | ||
|  | ||
| const details: AccordionGroupChangeEventDetail[] = []; | ||
| accordionGroup.addEventListener('ionValueChange', (event: CustomEvent<AccordionGroupChangeEventDetail>) => { | ||
| details.push(event.detail); | ||
| }); | ||
|  | ||
| page.body.appendChild(accordionGroup); | ||
| await page.waitForChanges(); | ||
|  | ||
| accordionGroup.value = 'first'; | ||
| await page.waitForChanges(); | ||
|  | ||
| const firstDetail = details.find((detail) => detail.value === 'first'); | ||
| expect(firstDetail?.initial).toBe(true); | ||
|  | ||
| const firstAccordion = accordionGroup.querySelector('ion-accordion[value="first"]')!; | ||
|  | ||
| expect(firstAccordion.classList.contains('accordion-expanded')).toEqual(true); | ||
| expect(firstAccordion.classList.contains('accordion-expanding')).toEqual(false); | ||
| expect(firstAccordion.classList.contains('accordion-animated')).toEqual(false); | ||
| }); | ||
|  | ||
| it('should animate when accordion is first opened by user', async () => { | ||
| const page = await newSpecPage({ | ||
| components: [Item, Accordion, AccordionGroup], | ||
| html: ` | ||
| <ion-accordion-group> | ||
| <ion-accordion value="first"> | ||
| <ion-item slot="header">Label</ion-item> | ||
| <div slot="content">Content</div> | ||
| </ion-accordion> | ||
| </ion-accordion-group> | ||
| `, | ||
| }); | ||
|  | ||
| const accordionGroup = page.body.querySelector('ion-accordion-group')!; | ||
|  | ||
| const details: AccordionGroupChangeEventDetail[] = []; | ||
| accordionGroup.addEventListener('ionValueChange', (event: CustomEvent<AccordionGroupChangeEventDetail>) => { | ||
| details.push(event.detail); | ||
| }); | ||
|  | ||
| await accordionGroup.requestAccordionToggle('first', true); | ||
| await page.waitForChanges(); | ||
|  | ||
| const lastDetail = details[details.length - 1]; | ||
| expect(lastDetail?.initial).toBe(false); | ||
|  | ||
| const firstAccordion = accordionGroup.querySelector('ion-accordion[value="first"]')!; | ||
| expect(firstAccordion.classList.contains('accordion-animated')).toEqual(true); | ||
| }); | ||
|  | ||
| // Verifies fix for https://github.com/ionic-team/ionic-framework/issues/27047 | ||
| it('should not have animated class when animated="false"', async () => { | ||
| const page = await newSpecPage({ | ||
|  | ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we revert the changes to this file since it doesn't do anything?