mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-04 17:01:56 +02:00
header click updates button
This commit is contained in:
parent
f817dbdf18
commit
ebe8aa7f78
1 changed files with 4 additions and 5 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue