-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcustomURLCellRenderer.ts
More file actions
34 lines (29 loc) · 1.08 KB
/
customURLCellRenderer.ts
File metadata and controls
34 lines (29 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Custom Cell Renderer for AgGrid URL Column Cells.
*
* AgGrid, by default, does not support opening links within its cells using keyboard navigation (Tab/Arrow keys/Enter key). This limitation hinders accessibility, particularly for users with disabilities who rely on keyboard navigation.
*
* This custom cell renderer addresses the issue by redirecting focus to the anchor (<a>) element within a cell when the cell gains focus. Consequently, when a user navigates to a link cell and presses the Enter key, the link is activated and opened.
*
* About cell renderers: https://www.ag-grid.com/javascript-data-grid/component-cell-renderer/
*/
export class URLCellRenderer {
eGui
params
init(params) {
this.params = params
this.eGui = document.createElement('div')
this.eGui.innerHTML = `<a class="govuk-link" key=${this.getUniqueKey()} href="${
params.value
}">${params.value}</a>`
}
getUniqueKey = () => {
return `${this.params.column.getColId()}-${this.params.rowIndex}`
}
getGui() {
return this.eGui
}
refresh() {
return false
}
}