-
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
+239
−11
Merged
Changes from all commits
Commits
Show all changes
14 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 31bda9d
Merge branch 'main' of github.com:ionic-team/ionic-framework into FW-…
ShaneK 10eabb3
chore(accordion-group): resetting accordion group changes since they …
ShaneK c1973cc
chore(accordion): variable name clarification
ShaneK 24a3db0
chore(accordion): clarifying group update handler variable naming
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
There are no files selected for viewing
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 |
|---|---|---|
|
|
@@ -200,6 +200,87 @@ 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> | ||
| `; | ||
|
|
||
| accordionGroup.value = 'first'; | ||
| page.body.appendChild(accordionGroup); | ||
|
|
||
| await page.waitForChanges(); | ||
|
|
||
| const firstAccordion = accordionGroup.querySelector('ion-accordion[value="first"]')!; | ||
|
|
||
| expect(firstAccordion.classList.contains('accordion-expanded')).toEqual(true); | ||
| expect(firstAccordion.classList.contains('accordion-expanding')).toEqual(false); | ||
|
Contributor
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 |
||
| }); | ||
|
|
||
| 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> | ||
| `; | ||
|
|
||
| page.body.appendChild(accordionGroup); | ||
| await page.waitForChanges(); | ||
|
|
||
| accordionGroup.value = 'first'; | ||
| await page.waitForChanges(); | ||
|
|
||
| const firstAccordion = accordionGroup.querySelector('ion-accordion[value="first"]')!; | ||
|
|
||
| expect(firstAccordion.classList.contains('accordion-expanded')).toEqual(true); | ||
| expect(firstAccordion.classList.contains('accordion-expanding')).toEqual(false); | ||
| }); | ||
|
|
||
| it('should not have animated class on first expansion', 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 firstAccordion = page.body.querySelector('ion-accordion[value="first"]')!; | ||
|
|
||
| // First expansion should not have the animated class | ||
| accordionGroup.value = 'first'; | ||
| await page.waitForChanges(); | ||
|
|
||
| expect(firstAccordion.classList.contains('accordion-animated')).toEqual(false); | ||
| expect(firstAccordion.classList.contains('accordion-expanded')).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({ | ||
|
|
||
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 |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { IonHeader, IonTitle, IonToolbar, IonPage, IonContent, IonAccordionGroup, IonAccordion, IonItem, IonLabel } from '@ionic/react'; | ||
| import { useEffect, useRef } from 'react'; | ||
|
|
||
| const AccordionGroup: React.FC = () => { | ||
| const accordionGroup = useRef<null | HTMLIonAccordionGroupElement>(null); | ||
|
|
||
| useEffect(() => { | ||
| if (!accordionGroup.current) { | ||
| return; | ||
| } | ||
|
|
||
| accordionGroup.current.value = ['first', 'third']; | ||
| }, []); | ||
|
|
||
| return ( | ||
| <IonPage> | ||
| <IonHeader> | ||
| <IonToolbar> | ||
| <IonTitle>Accordion Group</IonTitle> | ||
| </IonToolbar> | ||
| </IonHeader> | ||
| <IonContent> | ||
| <IonAccordionGroup ref={accordionGroup} multiple={true}> | ||
| <IonAccordion value="first"> | ||
| <IonItem slot="header" color="light"> | ||
| <IonLabel>First Accordion</IonLabel> | ||
| </IonItem> | ||
| <div className="ion-padding" slot="content"> | ||
| First Content | ||
| </div> | ||
| </IonAccordion> | ||
| <IonAccordion value="second"> | ||
| <IonItem slot="header" color="light"> | ||
| <IonLabel>Second Accordion</IonLabel> | ||
| </IonItem> | ||
| <div className="ion-padding" slot="content"> | ||
| Second Content | ||
| </div> | ||
| </IonAccordion> | ||
| <IonAccordion value="third"> | ||
| <IonItem slot="header" color="light"> | ||
| <IonLabel>Third Accordion</IonLabel> | ||
| </IonItem> | ||
| <div className="ion-padding" slot="content"> | ||
| Third Content | ||
| </div> | ||
| </IonAccordion> | ||
| </IonAccordionGroup> | ||
| </IonContent> | ||
| </IonPage> | ||
| ); | ||
| }; | ||
|
|
||
| export default AccordionGroup; |
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
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.
Did you undo the rename here?