Skip to content

Commit

Permalink
fix(alert): Sets autoCloseDuration to "medium" by default (#7157)
Browse files Browse the repository at this point in the history
**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.
  • Loading branch information
driskull authored Jun 17, 2023
1 parent 72c5943 commit 1b9a8ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/calcite-components/src/components/alert/alert.e2e.ts
Original file line number Diff line number Diff line change
@@ -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 = `
<div slot="title">Title Text</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/calcite-components/src/components/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down

0 comments on commit 1b9a8ed

Please sign in to comment.