mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-16 06:24:12 +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
|
// Add event listeners to table headers for sorting
|
||||||
initializeTableHeaders() {
|
initializeTableHeaders() {
|
||||||
this.tableHeaders.forEach(header => {
|
this.tableHeaders.forEach(header => {
|
||||||
|
header.addEventListener('click', event => {
|
||||||
// add event listener to respond to clicks on the button
|
|
||||||
|
|
||||||
header.addEventListener('click', function(event) {
|
|
||||||
let button = header.querySelector('.usa-table__header__button')
|
let button = header.querySelector('.usa-table__header__button')
|
||||||
const sortBy = header.getAttribute('data-sortable');
|
const sortBy = header.getAttribute('data-sortable');
|
||||||
let order = 'asc';
|
let order = 'asc';
|
||||||
|
@ -509,7 +506,9 @@ export class BaseTable {
|
||||||
}
|
}
|
||||||
// load the results with the updated sort
|
// load the results with the updated sort
|
||||||
this.loadTable(1, sortBy, order);
|
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)) {
|
if (!button.contains(event.target)) {
|
||||||
// Simulate a button click
|
// Simulate a button click
|
||||||
button.click();
|
button.click();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue