diff --git a/app/assets/javascripts/discourse/app/initializers/post-decorations.js b/app/assets/javascripts/discourse/app/initializers/post-decorations.js index c62ef5b4588..162eec7de61 100644 --- a/app/assets/javascripts/discourse/app/initializers/post-decorations.js +++ b/app/assets/javascripts/discourse/app/initializers/post-decorations.js @@ -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); diff --git a/app/assets/javascripts/discourse/tests/acceptance/post-table-wrapper-test.js b/app/assets/javascripts/discourse/tests/acceptance/post-table-wrapper-test.js index 217303d2fcd..909a90bc6e6 100644 --- a/app/assets/javascripts/discourse/tests/acceptance/post-table-wrapper-test.js +++ b/app/assets/javascripts/discourse/tests/acceptance/post-table-wrapper-test.js @@ -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" + ); }); });