Skip to content

Commit

Permalink
header click updates button
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-kennedy-ecs committed Dec 23, 2024
1 parent f817dbd commit ebe8aa7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/registrar/assets/src/js/getgov/table-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
Expand Down

0 comments on commit ebe8aa7

Please sign in to comment.