@@ -10,6 +10,7 @@ interface DropdownOption {
1010class Dropdown {
1111 private readonly showInfo : boolean ;
1212 private readonly multipleAllowed : boolean ;
13+ private readonly selectMultipleWithCtrl : boolean ;
1314 private readonly changeCallback : ( values : string [ ] ) => void ;
1415
1516 private options : ReadonlyArray < DropdownOption > = [ ] ;
@@ -34,10 +35,12 @@ class Dropdown {
3435 * @param dropdownType The type of content the dropdown is being used for.
3536 * @param changeCallback A callback to be invoked when the selected item(s) of the dropdown changes.
3637 * @returns The Dropdown instance.
38+ * @param selectMultipleWithCtrl Select multiple items using Ctrl
3739 */
38- constructor ( id : string , showInfo : boolean , multipleAllowed : boolean , dropdownType : string , changeCallback : ( values : string [ ] ) => void ) {
40+ constructor ( id : string , showInfo : boolean , multipleAllowed : boolean , dropdownType : string , changeCallback : ( values : string [ ] ) => void , selectMultipleWithCtrl : boolean = true ) {
3941 this . showInfo = showInfo ;
4042 this . multipleAllowed = multipleAllowed ;
43+ this . selectMultipleWithCtrl = selectMultipleWithCtrl ;
4144 this . changeCallback = changeCallback ;
4245 this . elem = document . getElementById ( id ) ! ;
4346
@@ -80,7 +83,7 @@ class Dropdown {
8083 } else {
8184 const option = < HTMLElement | null > ( < HTMLElement > e . target ) . closest ( '.dropdownOption' ) ;
8285 if ( option !== null && option . parentNode === this . optionsElem && typeof option . dataset . id !== 'undefined' ) {
83- this . onOptionClick ( parseInt ( option . dataset . id ! ) ) ;
86+ this . onOptionClick ( parseInt ( option . dataset . id ! ) , e ) ;
8487 }
8588 }
8689 }
@@ -280,7 +283,7 @@ class Dropdown {
280283 * Select a dropdown option.
281284 * @param option The index of the option to select.
282285 */
283- private onOptionClick ( option : number ) {
286+ private onOptionClick ( option : number , event ?: MouseEvent ) {
284287 // Note: Show All is always the first option (0 index) when multiple selected items are allowed
285288 let change = false ;
286289 let doubleClick = this . doubleClickTimeout !== null && this . lastClicked === option ;
@@ -296,7 +299,7 @@ class Dropdown {
296299 }
297300 } else {
298301 // Single Click
299- if ( this . multipleAllowed ) {
302+ if ( this . multipleAllowed || ( this . selectMultipleWithCtrl && event && ( event . ctrlKey || event . metaKey ) ) ) {
300303 // Multiple dropdown options can be selected
301304 if ( option === 0 ) {
302305 // Show All was selected
0 commit comments