@adobe-commerce/elsie 2.1.0 → 2.1.1-alpha-20260925105812

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @adobe-commerce/elsie
2
2
 
3
+ ## 2.1.1-alpha-20260925105812
4
+
5
+ ### Patch Changes
6
+
7
+ - e06c05f: fix(a11y): Checkbox now derives its internal label/description ids
8
+ from the unique `id` prop when provided, instead of the (often shared) `name`
9
+ prop, so two checkboxes with the same `name` no longer produce duplicate DOM
10
+ ids that cause screen readers to announce the wrong checkbox's label (WCAG
11
+ 4.1.2)
12
+
3
13
  ## 2.1.0
4
14
 
5
15
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe-commerce/elsie",
3
- "version": "2.1.0",
3
+ "version": "2.1.1-alpha-20260925105812",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "description": "Domain Package SDK",
6
6
  "engines": {
@@ -39,12 +39,14 @@ export const Checkbox: FunctionComponent<CheckboxProps> = ({
39
39
  description = '',
40
40
  className,
41
41
  checked,
42
+ id,
42
43
  ...props
43
44
  }) => {
44
45
  const [isChecked, setIsChecked] = useState(
45
46
  checked === undefined ? false : checked,
46
47
  );
47
48
  const ref = useRef<HTMLInputElement>(null);
49
+ const baseId = id ?? name;
48
50
 
49
51
  const handleCheckboxChange = (e: ChangeEvent<HTMLInputElement>) => {
50
52
  props.onChange?.(e);
@@ -73,6 +75,7 @@ export const Checkbox: FunctionComponent<CheckboxProps> = ({
73
75
  >
74
76
  <input
75
77
  ref={ref}
78
+ id={id}
76
79
  name={name}
77
80
  value={value}
78
81
  type="checkbox"
@@ -92,8 +95,8 @@ export const Checkbox: FunctionComponent<CheckboxProps> = ({
92
95
  {'\u200B'}
93
96
  <span
94
97
  aria-checked={isChecked ? 'true' : 'false'}
95
- aria-labelledby={`${name}-label`}
96
- aria-describedby={description ? `${name}-description` : undefined}
98
+ aria-labelledby={`${baseId}-label`}
99
+ aria-describedby={description ? `${baseId}-description` : undefined}
97
100
  className={classes([
98
101
  'dropin-checkbox__box',
99
102
  ['dropin-checkbox__box--error', error],
@@ -113,7 +116,7 @@ export const Checkbox: FunctionComponent<CheckboxProps> = ({
113
116
  </div>
114
117
 
115
118
  <div
116
- id={`${name}-label`}
119
+ id={`${baseId}-label`}
117
120
  className={classes([
118
121
  'dropin-checkbox__label',
119
122
  `dropin-checkbox__label--${size}`,
@@ -126,7 +129,7 @@ export const Checkbox: FunctionComponent<CheckboxProps> = ({
126
129
  <div />
127
130
  {description && (
128
131
  <div
129
- id={`${name}-description`}
132
+ id={`${baseId}-description`}
130
133
  role={'note'}
131
134
  className={classes([
132
135
  'dropin-checkbox__description',