From bbda15a9b360f3c36f5d2ca6de4d0c01156f978b Mon Sep 17 00:00:00 2001 From: Philipp Reinking Date: Sat, 17 Oct 2026 19:30:36 +0200 Subject: [PATCH 1/4] fix(Label): readable help text with an id for aria-describedby (BITS-289) Co-Authored-By: Claude Sonnet 5.5 --- src/Label/Label.stories.ts | 14 ++++++++++++++ src/Label/Label.vue | 3 ++- tests/Label.spec.ts | 39 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 tests/Label.spec.ts diff --git a/src/Label/Label.stories.ts b/src/Label/Label.stories.ts index ee24fa1..d55e330 100644 --- a/src/Label/Label.stories.ts +++ b/src/Label/Label.stories.ts @@ -1,4 +1,5 @@ import D9Label from "./Label.vue"; +import D9Input from "../Input/Input.vue"; export default { title: "Forms/Label", @@ -21,3 +22,16 @@ export const WithDescription = (args: Record) => ({ template: '', }); + +export const LinkedToField = (args: Record) => ({ + components: { D9Label, D9Input }, + setup() { + return { args }; + }, + // The help text gets the id "-help": point the field at it with aria-describedby. + template: ` +
+ + +
`, +}); diff --git a/src/Label/Label.vue b/src/Label/Label.vue index ebece5a..b03886e 100644 --- a/src/Label/Label.vue +++ b/src/Label/Label.vue @@ -11,7 +11,8 @@ > {{ description }} diff --git a/tests/Label.spec.ts b/tests/Label.spec.ts new file mode 100644 index 0000000..a0ae32d --- /dev/null +++ b/tests/Label.spec.ts @@ -0,0 +1,39 @@ +import { mount } from "@vue/test-utils"; +import { describe, expect, it } from "vitest"; +import { D9Label } from "../src"; + +describe("D9Label help text", () => { + it("gets the id -help next to -label", () => { + const wrapper = mount(D9Label, { + props: { id: "name", label: "Name", description: "Full name." }, + }); + + expect(wrapper.find("label").attributes("id")).toBe("name-label"); + expect(wrapper.find("#name-help").text()).toBe("Full name."); + }); + + it("has no help id without an id", () => { + const wrapper = mount(D9Label, { + props: { label: "Name", description: "Full name." }, + }); + + expect(wrapper.find("[id]").exists()).toBe(false); + }); + + it("renders no help element without a description", () => { + const wrapper = mount(D9Label, { props: { id: "name", label: "Name" } }); + + expect(wrapper.find("#name-help").exists()).toBe(false); + }); + + it("uses a text color with at least 4.5:1 contrast on white and grey-50", () => { + const wrapper = mount(D9Label, { + props: { id: "name", label: "Name", description: "Full name." }, + }); + const classes = wrapper.find("#name-help").classes(); + + // grey is slate: 500 is 4.76:1 on white, 4.55:1 on grey-50; 400 is only 2.56 / 2.45 + expect(classes).toContain("text-grey-500"); + expect(classes).not.toContain("text-grey-400"); + }); +}); From 10da847156fd10db9b95566200f7d562d9ac1c6c Mon Sep 17 00:00:00 2001 From: Philipp Reinking Date: Sat, 17 Oct 2026 19:32:37 +0200 Subject: [PATCH 2/4] fix(Select): put aria-describedby on the button (BITS-289) Co-Authored-By: Claude Sonnet 5.5 --- src/Select/Select.vue | 26 +++++++++++++++++++++++++- tests/Select.spec.ts | 16 ++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/Select/Select.vue b/src/Select/Select.vue index b2982c6..6b6b26f 100644 --- a/src/Select/Select.vue +++ b/src/Select/Select.vue @@ -5,11 +5,13 @@ @update:model-value="onSelect" :by="by" :disabled="isDisabled" + v-bind="wrapperAttrs" >
@@ -111,6 +113,12 @@ + + -