Skip to content

Commit

Permalink
fix(scrim): render text content inside scrim (#7509)
Browse files Browse the repository at this point in the history
**Related Issue:** #7032

## Summary

- Use new dom utility to test for content
- Add stories
- Update tests
  • Loading branch information
driskull authored Aug 11, 2023
1 parent b138c3b commit 643ce5d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/calcite-components/src/components/scrim/scrim.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ describe("calcite-scrim", () => {
const contentNode = await page.find(`calcite-scrim >>> .${CSS.content}`);

expect(contentNode).not.toBeNull();
expect(await contentNode.isVisible()).toBe(true);
expect(contentNode).not.toHaveAttribute("hidden");
});

describe("Responsive loading spinner", () => {
Expand Down
10 changes: 10 additions & 0 deletions packages/calcite-components/src/components/scrim/scrim.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,13 @@ export const darkModeRTL_TestOnly = (): string => html`
`;

darkModeRTL_TestOnly.parameters = { modes: modesDarkDefault };

export const textContent_TestOnly = (): string =>
html` <div tabindex="0" style="position: relative; width: 400px; height: 400px">
<calcite-scrim>This is a test.</calcite-scrim>
</div>`;

export const noContent_TestOnly = (): string =>
html` <div tabindex="0" style="position: relative; width: 400px; height: 400px">
<calcite-scrim></calcite-scrim>
</div>`;
4 changes: 2 additions & 2 deletions packages/calcite-components/src/components/scrim/scrim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ScrimMessages } from "./assets/scrim/t9n";
import { CSS, BREAKPOINTS } from "./resources";
import { createObserver } from "../../utils/observers";
import { Scale } from "../interfaces";
import { slotChangeHasAssignedElement } from "../../utils/dom";
import { slotChangeHasContent } from "../../utils/dom";

/**
* @slot - A slot for adding custom content, primarily loading information.
Expand Down Expand Up @@ -132,7 +132,7 @@ export class Scrim implements LocalizedComponent, T9nComponent {
// --------------------------------------------------------------------------

private handleDefaultSlotChange = (event: Event): void => {
this.hasContent = slotChangeHasAssignedElement(event);
this.hasContent = slotChangeHasContent(event);
};

private storeLoaderEl = (el: HTMLCalciteLoaderElement): void => {
Expand Down

0 comments on commit 643ce5d

Please sign in to comment.