@@ -43,7 +43,6 @@ export const handleDeleteGlossary = () => {
4343export const handleAddGlossary = ( ) => {
4444 const saveGlossaryButton = document . getElementById ( 'pmf-admin-glossary-add' ) ;
4545 const modal = document . getElementById ( 'addGlossaryModal' ) ;
46- const modalBackdrop = document . getElementsByClassName ( 'modal-backdrop fade show' ) ;
4746
4847 if ( saveGlossaryButton ) {
4948 saveGlossaryButton . addEventListener ( 'click' , async ( event ) => {
@@ -57,9 +56,13 @@ export const handleAddGlossary = () => {
5756 const response = await createGlossary ( glossaryLanguage , glossaryItem , glossaryDefinition , csrfToken ) ;
5857
5958 if ( response ) {
60- modal . style . display = 'none' ;
61- modal . classList . remove ( 'show' ) ;
62- modalBackdrop [ 0 ] . parentNode . removeChild ( modalBackdrop [ 0 ] ) ;
59+ // Close modal properly using Bootstrap
60+ const bootstrapModal = bootstrap . Modal . getInstance ( modal ) ;
61+ bootstrapModal . hide ( ) ;
62+
63+ // Reset form fields for the next entry
64+ document . getElementById ( 'item' ) . value = '' ;
65+ document . getElementById ( 'definition' ) . value = '' ;
6366
6467 const tableBody = document . querySelector ( '#pmf-admin-glossary-table tbody' ) ;
6568 const row = addElement ( 'tr' , { } , [
@@ -95,8 +98,6 @@ export const onOpenUpdateGlossaryModal = () => {
9598 const glossaryLang = event . relatedTarget . getAttribute ( 'data-pmf-glossary-language' ) ;
9699 const response = await getGlossary ( glossaryId , glossaryLang ) ;
97100
98- console . log ( response . language ) ;
99-
100101 document . getElementById ( 'update-id' ) . value = response . id ;
101102 document . getElementById ( 'update-language' ) . value = response . language ;
102103 document . getElementById ( 'update-item' ) . value = response . item ;
0 commit comments