Repository navigation
feat(fab-list): add animated prop to disable the staggered reveal #31778
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
2
commits into
feature-9.1
Choose a base branch
from
FW-7991
base: feature-9.1
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.
Open
Changes from all commits
Commits
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
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
92 changes: 92 additions & 0 deletions
92
core/src/components/fab-list/test/animation/fab-list.e2e.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import { expect } from '@playwright/test'; | ||
| import type { Page } from '@playwright/test'; | ||
| import { configs, test } from '@utils/test/playwright'; | ||
|
|
||
| /** | ||
| * Returns each list button's `show` right after opening, when a | ||
| * staggered list has only shown its first button. | ||
| */ | ||
| const activateAndGetShownButtons = (page: Page, selector: 'ion-fab' | 'ion-fab-list' = 'ion-fab') => | ||
| page.locator(selector).evaluate(async (el: HTMLIonFabElement | HTMLIonFabListElement) => { | ||
| el.activated = true; | ||
| await new Promise((resolve) => setTimeout(resolve, 0)); | ||
| return Array.from(el.querySelectorAll('ion-fab-list ion-fab-button')).map( | ||
| (button) => (button as HTMLIonFabButtonElement).show | ||
| ); | ||
| }); | ||
|
|
||
| const listButtons = ` | ||
| <ion-fab-button><ion-icon name="logo-facebook"></ion-icon></ion-fab-button> | ||
| <ion-fab-button><ion-icon name="logo-twitter"></ion-icon></ion-fab-button> | ||
| <ion-fab-button><ion-icon name="logo-vimeo"></ion-icon></ion-fab-button> | ||
| `; | ||
|
|
||
| const fabMarkup = ({ fabButtonAttrs = '', fabListAttrs = '' } = {}) => ` | ||
| <ion-fab> | ||
| <ion-fab-button ${fabButtonAttrs}> | ||
| <ion-icon name="add"></ion-icon> | ||
| </ion-fab-button> | ||
| <ion-fab-list ${fabListAttrs}>${listButtons}</ion-fab-list> | ||
| </ion-fab> | ||
| `; | ||
|
|
||
| /** | ||
| * This behavior does not vary across modes/directions. | ||
| */ | ||
| configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => { | ||
| test.describe(title('fab-list: animation'), () => { | ||
| test('should show the list buttons one at a time by default', async ({ page }) => { | ||
| await page.setContent(fabMarkup(), config); | ||
|
|
||
| expect(await activateAndGetShownButtons(page)).toEqual([true, false, false]); | ||
| await expect(page.locator('ion-fab-list ion-fab-button').last()).toHaveClass(/fab-button-show/); | ||
| }); | ||
|
|
||
| test('should show the list buttons one at a time by default outside of a fab', async ({ page }) => { | ||
| await page.setContent(`<ion-fab-list>${listButtons}</ion-fab-list>`, config); | ||
|
|
||
| expect(await activateAndGetShownButtons(page, 'ion-fab-list')).toEqual([true, false, false]); | ||
| }); | ||
|
|
||
| test('should show all list buttons at once when animated is false outside of a fab', async ({ page }) => { | ||
| await page.setContent(`<ion-fab-list animated="false">${listButtons}</ion-fab-list>`, config); | ||
|
|
||
| expect(await activateAndGetShownButtons(page, 'ion-fab-list')).toEqual([true, true, true]); | ||
| }); | ||
|
|
||
| test('should show all list buttons at once when the animated config is false', async ({ page }) => { | ||
| await page.setContent(`<script>window.Ionic.config.animated = false;</script>${fabMarkup()}`, config); | ||
|
|
||
| expect(await activateAndGetShownButtons(page)).toEqual([true, true, true]); | ||
| }); | ||
|
|
||
| test('should show all list buttons at once when the user prefers reduced motion', async ({ page }) => { | ||
| await page.emulateMedia({ reducedMotion: 'reduce' }); | ||
| await page.setContent(fabMarkup(), config); | ||
|
|
||
| expect(await activateAndGetShownButtons(page)).toEqual([true, true, true]); | ||
| }); | ||
|
|
||
| test('should show all list buttons at once when the main fab button is not animated', async ({ page }) => { | ||
| await page.setContent(fabMarkup({ fabButtonAttrs: 'animated="false"' }), config); | ||
|
|
||
| expect(await activateAndGetShownButtons(page)).toEqual([true, true, true]); | ||
| }); | ||
|
|
||
| test('should show all list buttons at once when the list is not animated under an animated main fab button', async ({ | ||
| page, | ||
| }) => { | ||
| await page.setContent(fabMarkup({ fabListAttrs: 'animated="false"' }), config); | ||
|
|
||
| expect(await activateAndGetShownButtons(page)).toEqual([true, true, true]); | ||
| }); | ||
|
|
||
| test('should show the list buttons one at a time when the list is animated under a main fab button that is not', async ({ | ||
| page, | ||
| }) => { | ||
| await page.setContent(fabMarkup({ fabButtonAttrs: 'animated="false"', fabListAttrs: 'animated="true"' }), config); | ||
|
|
||
| expect(await activateAndGetShownButtons(page)).toEqual([true, false, false]); | ||
| }); | ||
| }); | ||
| }); |
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
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.
The docs table will show no default for this prop, since it has none. The JSDoc also doesn't say what an unset list does outside an
ion-fab, so a reader can't tell that it still shows its buttons one at a time: