@@ -594,6 +594,9 @@ async function removeUserFromGroup (row, groupName) {
594594}
595595
596596$ ( function ( ) {
597+ // Store the initial state of the CSV import instructions
598+ let initialImportCsvHtml = $ ( '#result-import-groups-csv' ) . html ( )
599+
597600 // Multiple user role change
598601 $ ( '.users.card .update-button' ) . on ( 'click' , function ( e ) {
599602 const newRole = $ ( this ) . attr ( 'data-target-role' )
@@ -645,6 +648,20 @@ $(function () {
645648 $ ( '#dlg-import-groups-csv' ) . modal ( 'show' )
646649 } )
647650
651+ $ ( '#dlg-import-groups-csv' ) . on ( 'hidden.bs.modal' , function ( ) {
652+ // Safeguard: Store initial instructions if undefined (do this once at page load)
653+ if ( typeof initialImportCsvHtml === 'undefined' ) {
654+ initialImportCsvHtml = $ ( '#result-import-groups-csv' ) . html ( )
655+ }
656+
657+ // Restore initial state
658+ $ ( '#result-import-groups-csv' ) . html ( initialImportCsvHtml )
659+ // Hide the process CSV button
660+ $ ( '.div-process-results-import' ) . addClass ( 'hidden' )
661+ $ ( '.process-csv' ) . prop ( 'disabled' , true )
662+ $ ( '#file-input' ) . val ( '' ) // Clear file input
663+ } )
664+
648665 $ ( '.process-csv' ) . on ( 'click' , function ( ) {
649666 // First disable the button
650667 $ ( this ) . prop ( 'disabled' , true )
0 commit comments