diff --git a/apps/website/screens/components/status-light/code/StatusLightCodePage.tsx b/apps/website/screens/components/status-light/code/StatusLightCodePage.tsx
index 849bd4c87b..404d7519b0 100644
--- a/apps/website/screens/components/status-light/code/StatusLightCodePage.tsx
+++ b/apps/website/screens/components/status-light/code/StatusLightCodePage.tsx
@@ -4,7 +4,6 @@ import DocFooter from "@/common/DocFooter";
import { TableCode } from "@/common/Code";
import Example from "@/common/example/Example";
import basicUsage from "./examples/basicUsage";
-import StatusBadge from "@/common/StatusBadge";
const sections = [
{
@@ -21,16 +20,16 @@ const sections = [
+
label
-
-
- label
-
+ string
- string
+ An auxiliary text that will add some context to the status. It is the only accessible text of the
+ component: without it, the status light is only a colored dot and it must be accompanied by a visible
+ element or by surrounding context that explains its meaning. Screen readers only announce the status when
+ a label is provided.
-
An auxiliary text that will add some context to the status.
-
diff --git a/apps/website/screens/components/status-light/overview/StatusLightOverviewPage.tsx b/apps/website/screens/components/status-light/overview/StatusLightOverviewPage.tsx
index e68a618211..4eab4e5829 100644
--- a/apps/website/screens/components/status-light/overview/StatusLightOverviewPage.tsx
+++ b/apps/website/screens/components/status-light/overview/StatusLightOverviewPage.tsx
@@ -32,7 +32,8 @@ const sections = [
easy recognition.
- Label: a short text description alongside the status light to provide additional context.
+ Label (Optional): a short text description alongside the status light to provide additional
+ context.
>
diff --git a/packages/lib/src/status-light/StatusLight.stories.tsx b/packages/lib/src/status-light/StatusLight.stories.tsx
index 2803979d89..39da09c196 100644
--- a/packages/lib/src/status-light/StatusLight.stories.tsx
+++ b/packages/lib/src/status-light/StatusLight.stories.tsx
@@ -11,6 +11,7 @@ export default {
const StatusLight = () => (
<>
+
@@ -77,6 +78,68 @@ const StatusLight = () => (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
>
);
diff --git a/packages/lib/src/status-light/StatusLight.test.tsx b/packages/lib/src/status-light/StatusLight.test.tsx
index 81177e3bd5..4465896029 100644
--- a/packages/lib/src/status-light/StatusLight.test.tsx
+++ b/packages/lib/src/status-light/StatusLight.test.tsx
@@ -2,18 +2,15 @@ import { render } from "@testing-library/react";
import DxcStatusLight from "./StatusLight";
describe("StatusLight component tests", () => {
- test("StatusLight renders with correct label", () => {
- const { getByText } = render();
- expect(getByText("Status Light Test")).toBeTruthy();
- });
- test("StatusLight renders with role 'status'", () => {
- const { getByRole } = render();
- expect(getByRole("status")).toBeTruthy();
+ test("StatusLight with label has role status and shows the label", () => {
+ const { getByRole } = render();
+ const status = getByRole("status");
+ expect(status.textContent).toBe("Online");
});
- test("StatusLight dot is aria-hidden", () => {
- const { container } = render();
- const dot = container.querySelector("div[aria-hidden='true']");
- expect(dot).toBeTruthy();
+ test("StatusLight without label has no status role, since there is nothing to announce", () => {
+ const { queryByRole, container } = render();
+ expect(queryByRole("status")).toBeNull();
+ expect(container.querySelector("[aria-hidden='true']")).not.toBeNull();
});
});
diff --git a/packages/lib/src/status-light/StatusLight.tsx b/packages/lib/src/status-light/StatusLight.tsx
index 7b1d000caf..2748ecf094 100644
--- a/packages/lib/src/status-light/StatusLight.tsx
+++ b/packages/lib/src/status-light/StatusLight.tsx
@@ -69,11 +69,13 @@ const Label = styled.span<{
export default function DxcStatusLight({ label, mode = "default", size = "medium" }: StatusLightProps) {
return (
-
+
-
+ {label && (
+
+ )}
);
}
diff --git a/packages/lib/src/status-light/types.ts b/packages/lib/src/status-light/types.ts
index e65c14650f..0fe3add3c4 100644
--- a/packages/lib/src/status-light/types.ts
+++ b/packages/lib/src/status-light/types.ts
@@ -6,9 +6,11 @@ export type StatusLightProps = {
*/
mode?: Mode;
/**
- * An auxiliar text that will add some context to the status.
+ * An auxiliar text that will add some context to the status. It is the only accessible text of the component:
+ * without it, the status light is only a colored dot and it must be accompanied by a visible element or by
+ * surrounding context that explains its meaning. Screen readers only announce the status when a label is provided.
*/
- label: string;
+ label?: string;
/**
* Size of the component. Should be defined based on its importance and/or available space.
*/