Skip to content

Commit b18d830

Browse files
authored
Merge pull request #398 from jenkinsci/table-rows
Fix redrawing of broken details icon state
2 parents 8700f66 + c24d665 commit b18d830

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/main/webapp/js/table.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,27 @@ jQuery3(document).ready(function () {
132132
});
133133

134134
table.on('draw.dt', function () {
135+
// Re-enable tooltips
135136
table.find('[data-bs-toggle="tooltip"]').each(function () {
136137
const tooltip = new bootstrap5.Tooltip($(this)[0]);
137138
tooltip.enable();
138139
});
139-
table.find('.details-icon-close').each(function () {
140-
$(this).hide();
141-
});
142-
table.find('.details-icon-open').each(function () {
143-
$(this).show();
144-
});
145-
table.rows().every(function () {
146-
this.child.hide();
147-
});
140+
141+
// Re-draw details icon state
142+
dataTable.rows().every(function (rowIndex, tableLoop, rowLoop) {
143+
const tr = $(this.node());
144+
const openRowButton = tr.find('.details-icon-open');
145+
const closeRowButton = tr.find('.details-icon-close');
146+
147+
if (this.child.isShown()) {
148+
openRowButton.hide();
149+
closeRowButton.show();
150+
}
151+
else {
152+
openRowButton.show();
153+
closeRowButton.hide();
154+
}
155+
} );
148156
});
149157

150158
if (table.is(":visible")) {
@@ -156,7 +164,8 @@ jQuery3(document).ready(function () {
156164
});
157165
}
158166

159-
// Since Jenkins 2.406 Prototype has been removed from core.
167+
// TODO: Remove this block once Jenkins 2.426.1 is released
168+
// Since Jenkins 2.406 Prototype has been removed.
160169
// So we basically do not need to support a custom serialization of the data-tables state
161170
// anymore. We can now use the default auto-save functionality of DataTables.
162171
if (typeof Prototype === 'object') {

0 commit comments

Comments
 (0)