Skip to content

Commit 147ffc6

Browse files
Sarath PillaiSarath Pillai
authored andcommitted
add support for custom chartId and fix modal ARIA labeling
1 parent a503302 commit 147ffc6

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

packages/core/src/components/essentials/modal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class Modal extends Component {
104104
<div class="cds--modal-container">
105105
<div class="cds--modal-header">
106106
107-
<p class="cds--modal-header__label cds--type-delta" id="modal-title">${title}</p>
107+
<p class="cds--modal-header__label cds--type-delta" id="${id}__modal-title">${title}</p>
108108
109109
<p class="cds--modal-header__heading cds--type-beta" id="${id}__modal-description">${sanitizeText(
110110
options.title

packages/core/src/interfaces/charts.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ import type {
3434
* Base chart options common to any chart
3535
*/
3636
export interface BaseChartOptions {
37+
/**
38+
* Optional custom chart ID
39+
*/
40+
chartId?: string
3741
/*
3842
* aria-labels and other accessibility options
3943
*/

packages/core/src/services/essentials/dom-utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,15 @@ export class DOMUtils extends Service {
251251
}
252252

253253
private initializeID() {
254-
this.chartID = Math.floor((1 + Math.random()) * 0x1000000000000).toString(16)
254+
// Check if user provided a custom chartId in options
255+
const customId = this.model.getOptions().chartId
256+
257+
if (customId) {
258+
this.chartID = customId
259+
} else {
260+
// Generate random ID as fallback
261+
this.chartID = Math.floor((1 + Math.random()) * 0x1000000000000).toString(16)
262+
}
255263
}
256264

257265
addMainContainer() {

0 commit comments

Comments
 (0)