Skip to content

Commit

Permalink
Prevent multiple clicks of toggle button during draw
Browse files Browse the repository at this point in the history
  • Loading branch information
abeverley committed Sep 20, 2023
1 parent c1e6e98 commit f98697f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/frontend/components/data-table/lib/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,12 +566,17 @@ class DataTableComponent extends Component {
//Re-initialize more-less components after initialisation is complete
moreLess.reinitialize()

// (Re)enable wide-table toggle button each time. It is disabled during
// any drawing to prevent it being clicked multiple times during a draw
this.el.DataTable().button(0).enable();

this.bindClickHandlersAfterDraw(conf)
}

conf['buttons'] = [
{
text: 'Expand table',
enabled: false,
className: 'btn btn-small btn-toggle-off',
action: function ( e, dt, node, config ) {
if (self.inFullWidthMode) {
Expand All @@ -594,6 +599,8 @@ class DataTableComponent extends Component {
this.el.removeClass('dtr-column collapsed');
this.el.DataTable(conf)
this.el.parent().addClass('data-table__container--scrollable')
// See comments above regarding preventing multiple clicks
this.el.DataTable().button(0).disable();
this.el.closest('.dataTables_wrapper').find('.btn-toggle-off').toggleClass(['btn-toggle', 'btn-toggle-off'])
}

Expand All @@ -602,6 +609,8 @@ class DataTableComponent extends Component {
conf.responsive = this.originalResponsiveObj
this.el.DataTable().destroy();
this.el.DataTable(conf)
// See comments above regarding preventing multiple clicks
this.el.DataTable().button(0).disable();
}

bindClickHandlersAfterDraw(conf) {
Expand Down

0 comments on commit f98697f

Please sign in to comment.