diff --git a/src/registrar/assets/src/js/getgov/table-base.js b/src/registrar/assets/src/js/getgov/table-base.js index 8f47ca53a..97c256734 100644 --- a/src/registrar/assets/src/js/getgov/table-base.js +++ b/src/registrar/assets/src/js/getgov/table-base.js @@ -495,10 +495,7 @@ export class BaseTable { // Add event listeners to table headers for sorting initializeTableHeaders() { this.tableHeaders.forEach(header => { - - // add event listener to respond to clicks on the button - - header.addEventListener('click', function(event) { + header.addEventListener('click', event => { let button = header.querySelector('.usa-table__header__button') const sortBy = header.getAttribute('data-sortable'); let order = 'asc'; @@ -509,7 +506,9 @@ export class BaseTable { } // load the results with the updated sort this.loadTable(1, sortBy, order); - // Check if the click occurred outside the button + // If the click occurs outside of the button, need to simulate a button click in order + // for USWDS listener on the button to execute. + // Check first to see if click occurs outside of the button if (!button.contains(event.target)) { // Simulate a button click button.click();