diff --git a/core/src/components/button/button.tsx b/core/src/components/button/button.tsx index 4475e1374e..c588bc893d 100644 --- a/core/src/components/button/button.tsx +++ b/core/src/components/button/button.tsx @@ -21,6 +21,7 @@ import { createColorClasses, openURL } from '../../utils/theme'; export class Button implements ComponentInterface { private inToolbar = false; + private inItem = false; @Element() el!: HTMLElement; @@ -105,6 +106,7 @@ export class Button implements ComponentInterface { componentWillLoad() { this.inToolbar = !!this.el.closest('ion-buttons'); + this.inItem = !!this.el.closest('ion-item') || !!this.el.closest('ion-item-divider'); } @Listen('click') @@ -155,11 +157,12 @@ export class Button implements ComponentInterface { } hostData() { - const { buttonType, disabled, color, expand, hasIconOnly, shape, size, strong } = this; + const { buttonType, disabled, color, expand, hasIconOnly, shape, strong } = this; let fill = this.fill; if (fill === undefined) { fill = this.inToolbar ? 'clear' : 'solid'; } + const size = this.size === undefined && this.inItem ? 'small' : this.size; return { 'aria-disabled': disabled ? 'true' : null, class: { diff --git a/core/src/components/button/test/dynamic/e2e.ts b/core/src/components/button/test/dynamic/e2e.ts new file mode 100644 index 0000000000..48c4f0fa06 --- /dev/null +++ b/core/src/components/button/test/dynamic/e2e.ts @@ -0,0 +1,31 @@ +import { newE2EPage } from '@stencil/core/testing'; + +test('button: dynamic', async () => { + const page = await newE2EPage({ + url: '/src/components/button/test/dynamic?ionic:_testing=true' + }); + + const compares = []; + + compares.push(await page.compareScreenshot()); + + await page.click('#add-item-button'); + + compares.push(await page.compareScreenshot('add item button')); + + await page.click('#add-item-divider-button'); + + compares.push(await page.compareScreenshot('add item divider button')); + + await page.click('#change-item-button'); + + compares.push(await page.compareScreenshot('change item button size')); + + await page.click('#change-item-divider-button'); + + compares.push(await page.compareScreenshot('change item divider button size')); + + for (const compare of compares) { + expect(compare).toMatchScreenshot(); + } +}); diff --git a/core/src/components/button/test/dynamic/index.html b/core/src/components/button/test/dynamic/index.html new file mode 100644 index 0000000000..f4175446b4 --- /dev/null +++ b/core/src/components/button/test/dynamic/index.html @@ -0,0 +1,68 @@ + + + +
+ +