From 1b9a8edc1b7fab87899bd59c74ad036b5f53140c Mon Sep 17 00:00:00 2001 From: Matt Driscoll Date: Fri, 16 Jun 2023 17:17:02 -0700 Subject: [PATCH] fix(alert): Sets autoCloseDuration to "medium" by default (#7157) **Related Issue:** #6363 ## Summary fix(alert): Sets autoCloseDuration to "medium" by default. #6363 @jcfranco ~~can we have linting to prevent having any conditional defaults? If not, we should maybe update conventions to say not to do this~~ Lets discuss how we can properly document and test this pattern. --- .../src/components/alert/alert.e2e.ts | 11 ++++++++++- .../calcite-components/src/components/alert/alert.tsx | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/calcite-components/src/components/alert/alert.e2e.ts b/packages/calcite-components/src/components/alert/alert.e2e.ts index 1c266cf3a89..aad265b893e 100644 --- a/packages/calcite-components/src/components/alert/alert.e2e.ts +++ b/packages/calcite-components/src/components/alert/alert.e2e.ts @@ -1,9 +1,18 @@ import { E2EElement, E2EPage, newE2EPage } from "@stencil/core/testing"; import { html } from "../../../support/formatting"; -import { accessible, hidden, HYDRATED_ATTR, renders, t9n } from "../../tests/commonTests"; +import { accessible, defaults, hidden, HYDRATED_ATTR, renders, t9n } from "../../tests/commonTests"; import { getElementXY } from "../../tests/utils"; import { CSS, DURATIONS } from "./resources"; +describe("defaults", () => { + defaults("calcite-alert", [ + { + propertyName: "autoCloseDuration", + defaultValue: "medium" + } + ]); +}); + describe("calcite-alert", () => { const alertContent = `
Title Text
diff --git a/packages/calcite-components/src/components/alert/alert.tsx b/packages/calcite-components/src/components/alert/alert.tsx index d748079d228..a5c84406150 100644 --- a/packages/calcite-components/src/components/alert/alert.tsx +++ b/packages/calcite-components/src/components/alert/alert.tsx @@ -100,7 +100,7 @@ export class Alert implements OpenCloseComponent, LoadableComponent, T9nComponen @Prop({ reflect: true }) autoClose = false; /** Specifies the duration before the component automatically closes (only use with `autoClose`). */ - @Prop({ reflect: true }) autoCloseDuration: AlertDuration = this.autoClose ? "medium" : null; + @Prop({ reflect: true }) autoCloseDuration: AlertDuration = "medium"; /** Specifies the kind of the component (will apply to top border and icon). */ @Prop({ reflect: true }) kind: Extract<