@@ -85,10 +85,19 @@ export class KbqListSelectAllEvent<T> {
8585 ) { }
8686}
8787
88+ /**
89+ * Event class that occurs when copying an item from the KbqListSelection.
90+ * Used to pass data about the copied item and copy context.
91+ *
92+ * @param source - instance of KbqListSelection
93+ * @param option - instance of KbqListOption
94+ * @param event - original keyboard event (optional) that triggered the copy
95+ */
8896export class KbqListCopyEvent < T > {
8997 constructor (
9098 public source : KbqListSelection ,
91- public option : T
99+ public option : T ,
100+ public event ?: KeyboardEvent
92101 ) { }
93102}
94103
@@ -482,8 +491,7 @@ export class KbqListSelection implements AfterContentInit, AfterViewInit, OnDest
482491
483492 return ;
484493 } else if ( isCopy ( event ) ) {
485- this . copyActiveOption ( ) ;
486- event . preventDefault ( ) ;
494+ this . copyActiveOption ( event ) ;
487495
488496 return ;
489497 } else if ( [ SPACE , ENTER ] . includes ( keyCode ) ) {
@@ -615,19 +623,19 @@ export class KbqListSelection implements AfterContentInit, AfterViewInit, OnDest
615623 this . onSelectAll . emit ( new KbqListSelectAllEvent ( this , optionsToSelect ) ) ;
616624 }
617625
618- private copyActiveOption ( ) {
619- if ( ! this . keyManager . activeItem ) {
620- return ;
621- }
626+ private copyActiveOption ( event : KeyboardEvent ) {
627+ if ( ! this . keyManager . activeItem ) return ;
622628
623629 const option = this . keyManager . activeItem ;
624630
625631 option . preventBlur = true ;
626632
627- if ( this . onCopy . observers . length ) {
628- this . onCopy . emit ( new KbqListCopyEvent ( this , option ) ) ;
633+ if ( this . onCopy . observed ) {
634+ this . onCopy . emit ( new KbqListCopyEvent ( this , option , event ) ) ;
629635 } else {
630636 this . onCopyDefaultHandler ( ) ;
637+
638+ event . preventDefault ( ) ;
631639 }
632640
633641 option . preventBlur = false ;
0 commit comments