@@ -121,7 +121,7 @@ const dropDownElements = document.querySelectorAll('.dropdown');
121121const getDegreeElement = getRange ( 'animation' ) ;
122122const getRadioButtonSetElement = getRadioButtonSet ( 'animation' ) ;
123123const getDurationElement = getInputSpinner ( 'animation' ) ;
124- const events = [ " dragover" , " drop" ] ;
124+ const events = [ ' dragover' , ' drop' ] ;
125125
126126if ( openSidePanelButton ) {
127127 openSidePanelButton . style . display = 'none' ;
@@ -333,10 +333,10 @@ document.addEventListener('click', (e: Event) => {
333333} ) ;
334334
335335// Disable file opening in browser
336- for ( let event of events ) {
336+ for ( let event of events ) {
337337 document . addEventListener ( event , ( e ) => {
338338 e . preventDefault ( ) ;
339- } )
339+ } ) ;
340340}
341341
342342// clicking on the menu icon should close the nav bar
@@ -432,6 +432,28 @@ getRadioButtonSetElement.forEach((radioButton: HTMLInputElement) => {
432432
433433// configuring dropdown menu
434434dropDownElements . forEach ( ( dropDown ) => {
435+ // add click event listener to the dropdown parent element
436+ dropDown . addEventListener ( 'click' , ( e ) => {
437+ // keep dropdown open when a subitem is clicked on
438+ e . stopPropagation ( ) ;
439+ const target = e . target as HTMLElement ;
440+ if ( ! dropDown . children [ 0 ] . innerHTML . includes ( target . outerHTML ) ) return ;
441+
442+ const listElement = dropDown . lastElementChild as HTMLElement ;
443+ if ( listElement . id === 'showList' ) {
444+ listElement . id = '' ;
445+ return ;
446+ }
447+
448+ // clear other open dropdown menus
449+ dropDownElements . forEach ( ( dropdown ) => {
450+ const listElement = dropdown . lastElementChild as HTMLElement ;
451+ listElement . id = '' ;
452+ } ) ;
453+
454+ listElement . id = 'showList' ;
455+ } ) ;
456+
435457 const listElement = dropDown . lastElementChild as HTMLElement ;
436458
437459 // loop through children of dropdown and add event listener to each child
0 commit comments