-
Notifications
You must be signed in to change notification settings - Fork 179
Fix Datatable header button labels #5245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
70f7a45
5c4f839
e4a0a78
c16f67f
99b4efa
0523dda
db96c45
a0a6e03
e5b68c3
14da866
5251db2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,6 +150,24 @@ export function pushNotify(message, options = {}) { | |
| } | ||
| } | ||
|
|
||
| // rearrange table header labels so button labels are not part of header | ||
| export function customizeTableHeaders(tableId) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may be an aside - and we don't have to fix it here, but we appear to be using the phrase 'id' like tableId here, but really it's a tableIdSelector with Again, we don't have to fix it here, just noting it because apparently CONTENTID is also not an id, but an id selector.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a great suggestion because I spent a lot of time troubleshooting the fact that tableId from the path selector (real id) and CONTENTID (selector) were not the same format. |
||
| $(`${tableId} th.dt-orderable-asc`).each(function(_index, el) { | ||
| const sortButton = $(el).find('span.dt-column-order'); | ||
| const ariaLabel = sortButton.attr('aria-label'); | ||
| const labelId = `${el.textContent.replaceAll(' ', '_').toLowerCase()}_label`; | ||
| var labelSpan = document.getElementById(labelId); | ||
| if (labelSpan === null) { | ||
| labelSpan = document.createElement('span'); | ||
| labelSpan.id = labelId; | ||
| $('#header_labels').append(labelSpan); | ||
| } | ||
| labelSpan.textContent = ariaLabel; | ||
| sortButton.removeAttr('aria-label'); | ||
| sortButton.attr('aria-describedby', labelId); | ||
| }); | ||
| } | ||
|
|
||
| // Store a boolean value in localStorage | ||
| export function storeBoolean(key, value) { | ||
| localStorage.setItem(key, value ? 'true' : 'false'); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a javascript expert, so I don't know if using
this.is redundant here like it would be in ruby using self. In any case, why not just usethis.tableIdbelow?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't my first instinct either, but it appears
thisgets lost when referenced inside a callback. (from console.logs it was undefined). But assigning it to a normal variable instead of referencing the instance resolved the issue. This thread discusses the central issue https://stackoverflow.com/questions/8317724/javascript-class-variable-scope-in-callback-functionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK that makes sense.