From 911594f57800f90347f90934a44e9f87e543cbf0 Mon Sep 17 00:00:00 2001 From: ShaneK Date: Wed, 18 Nov 2026 13:57:39 -0800 Subject: [PATCH 1/2] feat(fab-list): add animated prop to disable the staggered button reveal --- core/api.txt | 1 + core/src/components.d.ts | 11 +++ core/src/components/fab-list/fab-list.tsx | 20 ++++- .../fab-list/test/animation/fab-list.e2e.ts | 77 +++++++++++++++++++ core/src/components/fab/fab.tsx | 4 + .../angular/src/lazy/directives/proxies.ts | 4 +- .../src/standalone/directives/ion-fab-list.ts | 4 +- packages/vue/src/proxies.ts | 3 +- 8 files changed, 117 insertions(+), 7 deletions(-) create mode 100644 core/src/components/fab-list/test/animation/fab-list.e2e.ts diff --git a/core/api.txt b/core/api.txt index 86a1d0251d7..7e04daee6c4 100644 --- a/core/api.txt +++ b/core/api.txt @@ -667,6 +667,7 @@ ion-fab-button,part,native ion-fab-list,shadow ion-fab-list,prop,activated,boolean,false,false,false +ion-fab-list,prop,animated,boolean,true,false,false ion-fab-list,prop,side,"bottom" | "end" | "start" | "top",'bottom',false,false ion-footer,none diff --git a/core/src/components.d.ts b/core/src/components.d.ts index af6fa7794f9..fd2671ed485 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -1207,6 +1207,11 @@ export namespace Components { * @default false */ "activated": boolean; + /** + * If `true`, the fab buttons in the list will show one at a time when the list opens. Inside an `ion-fab`, this is ignored and the main fab button's `animated` is used instead. + * @default true + */ + "animated": boolean; /** * The side the fab list will show on relative to the main fab button. * @default 'bottom' @@ -6364,6 +6369,11 @@ declare namespace LocalJSX { * @default false */ "activated"?: boolean; + /** + * If `true`, the fab buttons in the list will show one at a time when the list opens. Inside an `ion-fab`, this is ignored and the main fab button's `animated` is used instead. + * @default true + */ + "animated"?: boolean; /** * The side the fab list will show on relative to the main fab button. * @default 'bottom' @@ -9207,6 +9217,7 @@ declare namespace LocalJSX { interface IonFabListAttributes { "activated": boolean; "side": 'start' | 'end' | 'top' | 'bottom'; + "animated": boolean; } interface IonFooterAttributes { "collapse": 'fade'; diff --git a/core/src/components/fab-list/fab-list.tsx b/core/src/components/fab-list/fab-list.tsx index 1803f7f2c30..bebc13dad5a 100644 --- a/core/src/components/fab-list/fab-list.tsx +++ b/core/src/components/fab-list/fab-list.tsx @@ -1,6 +1,8 @@ import type { ComponentInterface } from '@stencil/core'; import { Component, Element, Host, Prop, Watch, h } from '@stencil/core'; +import { win } from '@utils/browser'; +import { config } from '../../global/config'; import { getIonMode } from '../../global/ionic-global'; @Component({ @@ -24,8 +26,7 @@ export class FabList implements ComponentInterface { const fabs = Array.from(this.el.querySelectorAll('ion-fab-button')); - // if showing the fabs add a timeout, else show immediately - const timeout = activated ? 30 : 0; + const timeout = activated && this.shouldAnimate() ? 30 : 0; fabs.forEach((fab, i) => { this.activateTimeouts.push(setTimeout(() => (fab.show = activated), i * timeout)); }); @@ -36,11 +37,26 @@ export class FabList implements ComponentInterface { */ @Prop() side: 'start' | 'end' | 'top' | 'bottom' = 'bottom'; + /** + * If `true`, the fab buttons in the list will show one at a time + * when the list opens. Inside an `ion-fab`, this is ignored and the + * main fab button's `animated` is used instead. + */ + @Prop() animated = true; + disconnectedCallback() { this.activateTimeouts.forEach(clearTimeout); this.activateTimeouts = []; } + private shouldAnimate() { + if (!this.animated || !config.getBoolean('animated', true)) { + return false; + } + + return !win?.matchMedia?.('(prefers-reduced-motion: reduce)').matches; + } + render() { const mode = getIonMode(this); return ( diff --git a/core/src/components/fab-list/test/animation/fab-list.e2e.ts b/core/src/components/fab-list/test/animation/fab-list.e2e.ts new file mode 100644 index 00000000000..4f3e8472d3e --- /dev/null +++ b/core/src/components/fab-list/test/animation/fab-list.e2e.ts @@ -0,0 +1,77 @@ +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 the first reveal. A + * staggered list has only shown its first button by then. + */ +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 = ` + + + +`; + +const fabMarkup = ({ fabButtonAttrs = '', fabListAttrs = '' } = {}) => ` + + + + + ${listButtons} + +`; + +/** + * 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 all list buttons at once when animated is false', async ({ page }) => { + // Inside an `ion-fab` the list follows the main button, so this tests the list on its own. + await page.setContent(`${listButtons}`, 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(`${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 follow the main fab button over the animated property of the list', async ({ page }) => { + await page.setContent(fabMarkup({ fabListAttrs: 'animated="false"' }), config); + + expect(await activateAndGetShownButtons(page)).toEqual([true, false, false]); + }); + }); +}); diff --git a/core/src/components/fab/fab.tsx b/core/src/components/fab/fab.tsx index 221335062e5..b3f28c9a7b4 100644 --- a/core/src/components/fab/fab.tsx +++ b/core/src/components/fab/fab.tsx @@ -41,6 +41,10 @@ export class Fab implements ComponentInterface { fab.activated = activated; } Array.from(this.el.querySelectorAll('ion-fab-list')).forEach((list) => { + if (fab) { + // set before activated so the list reads it when it opens + list.animated = fab.animated; + } list.activated = activated; }); } diff --git a/packages/angular/src/lazy/directives/proxies.ts b/packages/angular/src/lazy/directives/proxies.ts index 95ffa9eaba9..4831a21cd03 100644 --- a/packages/angular/src/lazy/directives/proxies.ts +++ b/packages/angular/src/lazy/directives/proxies.ts @@ -831,14 +831,14 @@ export declare interface IonFabButton extends Components.IonFabButton { @ProxyCmp({ - inputs: ['activated', 'side'] + inputs: ['activated', 'animated', 'side'] }) @Component({ selector: 'ion-fab-list', changeDetection: ChangeDetectionStrategy.OnPush, template: '', // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property - inputs: ['activated', 'side'], + inputs: ['activated', 'animated', 'side'], standalone: false }) export class IonFabList { diff --git a/packages/angular/src/standalone/directives/ion-fab-list.ts b/packages/angular/src/standalone/directives/ion-fab-list.ts index 2e2860c1a0a..baa24374936 100644 --- a/packages/angular/src/standalone/directives/ion-fab-list.ts +++ b/packages/angular/src/standalone/directives/ion-fab-list.ts @@ -10,14 +10,14 @@ import { defineCustomElement as defineIonFabList } from '@ionic/core/components/ @ProxyCmp({ defineCustomElementFn: defineIonFabList, - inputs: ['activated', 'side'] + inputs: ['activated', 'animated', 'side'] }) @Component({ selector: 'ion-fab-list', changeDetection: ChangeDetectionStrategy.OnPush, template: '', // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property - inputs: ['activated', 'side'], + inputs: ['activated', 'animated', 'side'], }) export class IonFabList { protected el: HTMLIonFabListElement; diff --git a/packages/vue/src/proxies.ts b/packages/vue/src/proxies.ts index aaaedee7512..8fc0b1d78f0 100644 --- a/packages/vue/src/proxies.ts +++ b/packages/vue/src/proxies.ts @@ -397,7 +397,8 @@ export const IonFabButton: StencilVueComponent = /*@__PURE__*/ export const IonFabList: StencilVueComponent = /*@__PURE__*/ defineContainer('ion-fab-list', defineIonFabList, [ 'activated', - 'side' + 'side', + 'animated' ]); From 9fa60703e79d7c3f9a9bcd3007736f433ef2b0ed Mon Sep 17 00:00:00 2001 From: ShaneK Date: Fri, 20 Nov 2026 08:58:02 -0800 Subject: [PATCH 2/2] feat(fab-list): let the list animated prop override the main fab button --- core/api.txt | 2 +- core/src/components.d.ts | 12 ++++----- core/src/components/fab-button/fab-button.tsx | 4 ++- core/src/components/fab-list/fab-list.tsx | 11 +++++--- .../fab-list/test/animation/fab-list.e2e.ts | 25 +++++++++++++++---- core/src/components/fab/fab.tsx | 4 --- 6 files changed, 36 insertions(+), 22 deletions(-) diff --git a/core/api.txt b/core/api.txt index 7e04daee6c4..61d821e7cd0 100644 --- a/core/api.txt +++ b/core/api.txt @@ -667,7 +667,7 @@ ion-fab-button,part,native ion-fab-list,shadow ion-fab-list,prop,activated,boolean,false,false,false -ion-fab-list,prop,animated,boolean,true,false,false +ion-fab-list,prop,animated,boolean | undefined,undefined,false,false ion-fab-list,prop,side,"bottom" | "end" | "start" | "top",'bottom',false,false ion-footer,none diff --git a/core/src/components.d.ts b/core/src/components.d.ts index fd2671ed485..fdc0f00293b 100644 --- a/core/src/components.d.ts +++ b/core/src/components.d.ts @@ -1130,7 +1130,7 @@ export namespace Components { */ "activated": boolean; /** - * If `true`, the fab button will animate between states, such as swapping its content for the close icon. + * If `true`, the fab button will animate between states, such as swapping its content for the close icon. As the main button of an `ion-fab`, it also sets whether the `ion-fab-list` buttons show one at a time, unless the list sets its own `animated`. * @default true */ "animated": boolean; @@ -1208,10 +1208,9 @@ export namespace Components { */ "activated": boolean; /** - * If `true`, the fab buttons in the list will show one at a time when the list opens. Inside an `ion-fab`, this is ignored and the main fab button's `animated` is used instead. - * @default true + * If `true`, the fab buttons in the list will show one at a time when the list opens. If not set, it follows the main fab button's `animated`. */ - "animated": boolean; + "animated"?: boolean; /** * The side the fab list will show on relative to the main fab button. * @default 'bottom' @@ -6284,7 +6283,7 @@ declare namespace LocalJSX { */ "activated"?: boolean; /** - * If `true`, the fab button will animate between states, such as swapping its content for the close icon. + * If `true`, the fab button will animate between states, such as swapping its content for the close icon. As the main button of an `ion-fab`, it also sets whether the `ion-fab-list` buttons show one at a time, unless the list sets its own `animated`. * @default true */ "animated"?: boolean; @@ -6370,8 +6369,7 @@ declare namespace LocalJSX { */ "activated"?: boolean; /** - * If `true`, the fab buttons in the list will show one at a time when the list opens. Inside an `ion-fab`, this is ignored and the main fab button's `animated` is used instead. - * @default true + * If `true`, the fab buttons in the list will show one at a time when the list opens. If not set, it follows the main fab button's `animated`. */ "animated"?: boolean; /** diff --git a/core/src/components/fab-button/fab-button.tsx b/core/src/components/fab-button/fab-button.tsx index f3df7973043..5543659ad55 100755 --- a/core/src/components/fab-button/fab-button.tsx +++ b/core/src/components/fab-button/fab-button.tsx @@ -52,7 +52,9 @@ export class FabButton implements ComponentInterface, AnchorInterface, ButtonInt /** * If `true`, the fab button will animate between states, such as - * swapping its content for the close icon. + * swapping its content for the close icon. As the main button of an + * `ion-fab`, it also sets whether the `ion-fab-list` buttons show one + * at a time, unless the list sets its own `animated`. */ @Prop() animated = true; diff --git a/core/src/components/fab-list/fab-list.tsx b/core/src/components/fab-list/fab-list.tsx index bebc13dad5a..11bdab4f11e 100644 --- a/core/src/components/fab-list/fab-list.tsx +++ b/core/src/components/fab-list/fab-list.tsx @@ -39,10 +39,10 @@ export class FabList implements ComponentInterface { /** * If `true`, the fab buttons in the list will show one at a time - * when the list opens. Inside an `ion-fab`, this is ignored and the - * main fab button's `animated` is used instead. + * when the list opens. If not set, it follows the main fab button's + * `animated`. */ - @Prop() animated = true; + @Prop() animated?: boolean; disconnectedCallback() { this.activateTimeouts.forEach(clearTimeout); @@ -50,7 +50,10 @@ export class FabList implements ComponentInterface { } private shouldAnimate() { - if (!this.animated || !config.getBoolean('animated', true)) { + const fabButton = this.el.closest('ion-fab')?.querySelector(':scope > ion-fab-button'); + const animated = this.animated ?? fabButton?.animated ?? true; + + if (!animated || !config.getBoolean('animated', true)) { return false; } diff --git a/core/src/components/fab-list/test/animation/fab-list.e2e.ts b/core/src/components/fab-list/test/animation/fab-list.e2e.ts index 4f3e8472d3e..d72259a7019 100644 --- a/core/src/components/fab-list/test/animation/fab-list.e2e.ts +++ b/core/src/components/fab-list/test/animation/fab-list.e2e.ts @@ -3,8 +3,8 @@ import type { Page } from '@playwright/test'; import { configs, test } from '@utils/test/playwright'; /** - * Returns each list button's `show` right after the first reveal. A - * staggered list has only shown its first button by then. + * 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) => { @@ -42,8 +42,13 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => { await expect(page.locator('ion-fab-list ion-fab-button').last()).toHaveClass(/fab-button-show/); }); - test('should show all list buttons at once when animated is false', async ({ page }) => { - // Inside an `ion-fab` the list follows the main button, so this tests the list on its own. + test('should show the list buttons one at a time by default outside of a fab', async ({ page }) => { + await page.setContent(`${listButtons}`, 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(`${listButtons}`, config); expect(await activateAndGetShownButtons(page, 'ion-fab-list')).toEqual([true, true, true]); @@ -68,9 +73,19 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => { expect(await activateAndGetShownButtons(page)).toEqual([true, true, true]); }); - test('should follow the main fab button over the animated property of the list', async ({ page }) => { + 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]); }); }); diff --git a/core/src/components/fab/fab.tsx b/core/src/components/fab/fab.tsx index b3f28c9a7b4..221335062e5 100644 --- a/core/src/components/fab/fab.tsx +++ b/core/src/components/fab/fab.tsx @@ -41,10 +41,6 @@ export class Fab implements ComponentInterface { fab.activated = activated; } Array.from(this.el.querySelectorAll('ion-fab-list')).forEach((list) => { - if (fab) { - // set before activated so the list reads it when it opens - list.animated = fab.animated; - } list.activated = activated; }); }