Skip to content

Commit b4048bb

Browse files
committed
Fix datatable click handler
1 parent e81fb62 commit b4048bb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

resources/js/project-report.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,17 @@ $(document).ready(function () {
119119
},
120120
});
121121

122-
$('#violationsTable tbody').on('click', 'tr[role=row]', function() {
123-
var tr = $(this).closest('tr');
122+
$('#violationsTable tbody').on('click', 'tr', function() {
123+
// the event handler might be executed on "tr" elements in sub tables, such as
124+
// code snippets or it might be a child-row (a tr, whose previous sibling has class dt-hasChild)
125+
if (!this.parentElement.parentElement.id === 'violationsTable') {
126+
return;
127+
}
128+
if (this.previousElementSibling !== null && this.previousElementSibling.classList.contains('dt-hasChild')) {
129+
return;
130+
}
131+
132+
var tr = $(this);
124133
var row = table.row( tr );
125134

126135
if ( row.child.isShown() ) {

0 commit comments

Comments
 (0)