mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
feat(toast): add global config toastDuration (#26425)
Co-authored-by: DwieDima <DwieDima@users.noreply.github.com>
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import type { Locator, TestInfo } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
import type { E2EPage, EventSpy } from '@utils/test/playwright';
|
||||
import { test } from '@utils/test/playwright';
|
||||
|
||||
@ -134,3 +134,31 @@ test.describe('toast: properties', () => {
|
||||
await expect(toast).toHaveClass(/my-custom-class/);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('toast: duration config', () => {
|
||||
test.beforeEach(({ skip }) => {
|
||||
skip.rtl();
|
||||
skip.mode('ios');
|
||||
});
|
||||
test('should have duration set to 0', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-toast></ion-toast>
|
||||
`);
|
||||
const toast = page.locator('ion-toast');
|
||||
await expect(toast).toHaveJSProperty('duration', 0);
|
||||
});
|
||||
|
||||
test('should have duration set to 5000', async ({ page }) => {
|
||||
await page.setContent(`
|
||||
<ion-toast></ion-toast>
|
||||
<script>
|
||||
window.Ionic = {
|
||||
config: { toastDuration: 5000 }
|
||||
}
|
||||
</script>
|
||||
`);
|
||||
|
||||
const toast = page.locator('ion-toast');
|
||||
await expect(toast).toHaveJSProperty('duration', 5000);
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import type { ComponentInterface, EventEmitter } from '@stencil/core';
|
||||
import { Component, Element, Event, Host, Method, Prop, h } from '@stencil/core';
|
||||
import { Component, Element, Event, h, Host, Method, Prop } from '@stencil/core';
|
||||
|
||||
import { config } from '../../global/config';
|
||||
import { getIonMode } from '../../global/ionic-global';
|
||||
import type {
|
||||
AnimationBuilder,
|
||||
@ -77,7 +78,7 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
* How many milliseconds to wait before hiding the toast. By default, it will show
|
||||
* until `dismiss()` is called.
|
||||
*/
|
||||
@Prop() duration = 0;
|
||||
@Prop() duration = config.getNumber('toastDuration', 0);
|
||||
|
||||
/**
|
||||
* Header to be shown in the toast.
|
||||
|
||||
Reference in New Issue
Block a user