11import { fomanticQuery } from '../modules/fomantic/base.ts' ;
22import { POST } from '../modules/fetch.ts' ;
3- import { queryElemChildren , queryElems , toggleElem } from '../utils/dom.ts' ;
3+ import { addDelegatedEventListener , queryElemChildren , queryElems , toggleElem } from '../utils/dom.ts' ;
44
55// if there are draft comments, confirm before reloading, to avoid losing comments
66function issueSidebarReloadConfirmDraftComment ( ) {
@@ -22,7 +22,7 @@ function issueSidebarReloadConfirmDraftComment() {
2222 window . location . reload ( ) ;
2323}
2424
25- class IssueSidebarComboList {
25+ export class IssueSidebarComboList {
2626 updateUrl : string ;
2727 updateAlgo : string ;
2828 selectionMode : string ;
@@ -95,9 +95,7 @@ class IssueSidebarComboList {
9595 }
9696 }
9797
98- async onItemClick ( e : Event ) {
99- const elItem = ( e . target as HTMLElement ) . closest ( '.item' ) ;
100- if ( ! elItem ) return ;
98+ async onItemClick ( elItem : HTMLElement , e : Event ) {
10199 e . preventDefault ( ) ;
102100 if ( elItem . hasAttribute ( 'data-can-change' ) && elItem . getAttribute ( 'data-can-change' ) !== 'true' ) return ;
103101
@@ -146,16 +144,13 @@ class IssueSidebarComboList {
146144 }
147145 this . initialValues = this . collectCheckedValues ( ) ;
148146
149- this . elDropdown . addEventListener ( 'click' , ( e ) => this . onItemClick ( e ) ) ;
147+ addDelegatedEventListener ( this . elDropdown , 'click' , '.item' , ( el , e ) => this . onItemClick ( el , e ) ) ;
150148
151149 fomanticQuery ( this . elDropdown ) . dropdown ( 'setting' , {
152150 action : 'nothing' , // do not hide the menu if user presses Enter
153151 fullTextSearch : 'exact' ,
152+ hideDividers : 'empty' ,
154153 onHide : ( ) => this . onHide ( ) ,
155154 } ) ;
156155 }
157156}
158-
159- export function initIssueSidebarComboList ( container : HTMLElement ) {
160- new IssueSidebarComboList ( container ) . init ( ) ;
161- }
0 commit comments