FIX: Ensure expand table works regardless of click event target (#21373)

In the expand table event handler, we currently rely on `event.target`
to select the table being expanded. Sometimes, the target is the svg icon
wrapped inside the button instead of the button itself. This throws
things off.

This change uses `currentTarget` which refers to the button
element even if the event originated from svg icon.
This commit is contained in:
Selase Krakani 2023-05-04 10:09:37 +00:00 committed by GitHub
parent b75c17fe42
commit 0424eb8db2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -158,7 +158,7 @@ export default {
}
function generateModal(event) {
const table = event.target.parentElement.nextElementSibling;
const table = event.currentTarget.parentElement.nextElementSibling;
const tempTable = table.cloneNode(true);
showModal("fullscreen-table").set("tableHtml", tempTable);

View File

@ -37,6 +37,7 @@ acceptance("Post Table Wrapper Test", function () {
await click(
`${postWithLargeTable} .fullscreen-table-wrapper .btn-expand-table`
);
assert.ok(
exists(".fullscreen-table-modal"),
"The fullscreen table modal appears"
@ -45,5 +46,15 @@ acceptance("Post Table Wrapper Test", function () {
exists(".fullscreen-table-modal table"),
"The table is present inside the modal"
);
await click(".fullscreen-table-modal .modal-close.close");
await click(
`${postWithLargeTable} .fullscreen-table-wrapper .btn-expand-table svg`
);
assert.ok(
exists(".fullscreen-table-modal"),
"Fullscreen table modal appears on clicking svg icon"
);
});
});