Skip to content

Commit 499414f

Browse files
eriklharperbenelan
authored andcommitted
fix(input-date-picker): add label property for screen readers and AT (#11995)
**Related Issue:** #8480 ## Summary This PR adds a `label` property to `calcite-input-date-picker` to support an accessible screen reading experience. <img width="681" alt="image" src="https://github.com/user-attachments/assets/f714c200-91e2-444d-ace4-9a04e90e63a9" />
1 parent c0a95ff commit 499414f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

packages/calcite-components/src/components/input-date-picker/input-date-picker.e2e.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ const animationDurationInMs = 200;
2525

2626
describe("calcite-input-date-picker", () => {
2727
describe("accessibility", () => {
28-
accessible(html`
29-
<calcite-label>
30-
Input Date Picker
31-
<calcite-input-date-picker></calcite-input-date-picker>
32-
</calcite-label>
33-
`);
28+
accessible(html` <calcite-input-date-picker label="Input Date Picker"></calcite-input-date-picker> `);
3429
});
3530

3631
describe("renders", () => {
@@ -70,6 +65,10 @@ describe("calcite-input-date-picker", () => {
7065
labelable("calcite-input-date-picker");
7166
});
7267

68+
describe("labelable range", () => {
69+
labelable("<calcite-input-date-picker range></calcite-input-date-picker>");
70+
});
71+
7372
describe("disabled", () => {
7473
disabled("calcite-input-date-picker");
7574
});

packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ export class InputDatePicker
198198
/** Specifies the heading level of the component's `heading` for proper document structure, without affecting visual styling. */
199199
@property({ type: Number, reflect: true }) headingLevel: HeadingLevel;
200200

201+
/** Accessible name for the component. */
202+
@property() label: string;
203+
201204
/** Defines the layout of the component. */
202205
@property({ reflect: true }) layout: "horizontal" | "vertical" = "horizontal";
203206

@@ -1100,6 +1103,7 @@ export class InputDatePicker
11001103
}}
11011104
disabled={disabled}
11021105
icon="calendar"
1106+
label={this.label}
11031107
oncalciteInputTextInput={this.calciteInternalInputInputHandler}
11041108
oncalciteInternalInputTextBlur={this.calciteInternalInputBlurHandler}
11051109
oncalciteInternalInputTextFocus={this.startInputFocus}
@@ -1184,6 +1188,7 @@ export class InputDatePicker
11841188
}}
11851189
disabled={disabled}
11861190
icon="calendar"
1191+
label={this.label}
11871192
oncalciteInputTextInput={this.calciteInternalInputInputHandler}
11881193
oncalciteInternalInputTextBlur={this.calciteInternalInputBlurHandler}
11891194
oncalciteInternalInputTextFocus={this.endInputFocus}

0 commit comments

Comments
 (0)