1
1
import { fomanticQuery } from '../modules/fomantic/base.ts' ;
2
2
import { POST } from '../modules/fetch.ts' ;
3
- import { queryElemChildren , queryElems , toggleElem } from '../utils/dom.ts' ;
3
+ import { addDelegatedEventListener , queryElemChildren , queryElems , toggleElem } from '../utils/dom.ts' ;
4
4
5
5
// if there are draft comments, confirm before reloading, to avoid losing comments
6
6
function issueSidebarReloadConfirmDraftComment ( ) {
@@ -22,7 +22,7 @@ function issueSidebarReloadConfirmDraftComment() {
22
22
window . location . reload ( ) ;
23
23
}
24
24
25
- class IssueSidebarComboList {
25
+ export class IssueSidebarComboList {
26
26
updateUrl : string ;
27
27
updateAlgo : string ;
28
28
selectionMode : string ;
@@ -95,9 +95,7 @@ class IssueSidebarComboList {
95
95
}
96
96
}
97
97
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 ) {
101
99
e . preventDefault ( ) ;
102
100
if ( elItem . hasAttribute ( 'data-can-change' ) && elItem . getAttribute ( 'data-can-change' ) !== 'true' ) return ;
103
101
@@ -146,16 +144,13 @@ class IssueSidebarComboList {
146
144
}
147
145
this . initialValues = this . collectCheckedValues ( ) ;
148
146
149
- this . elDropdown . addEventListener ( 'click' , ( e ) => this . onItemClick ( e ) ) ;
147
+ addDelegatedEventListener ( this . elDropdown , 'click' , '.item' , ( el , e ) => this . onItemClick ( el , e ) ) ;
150
148
151
149
fomanticQuery ( this . elDropdown ) . dropdown ( 'setting' , {
152
150
action : 'nothing' , // do not hide the menu if user presses Enter
153
151
fullTextSearch : 'exact' ,
152
+ hideDividers : 'empty' ,
154
153
onHide : ( ) => this . onHide ( ) ,
155
154
} ) ;
156
155
}
157
156
}
158
-
159
- export function initIssueSidebarComboList ( container : HTMLElement ) {
160
- new IssueSidebarComboList ( container ) . init ( ) ;
161
- }
0 commit comments