Skip to content

Commit 722886f

Browse files
authored
fix(list): multiple selection by keyboard on macos (#DS-2908) (#309)
1 parent b4c2dcc commit 722886f

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

packages/components-dev/list/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ <h2>Multiple selection: Keyboard</h2>
5454
multiple="keyboard"
5555
style="height: 100px; overflow-y: scroll"
5656
[autoSelect]="true"
57-
[disabled]="true"
57+
[disabled]="false"
5858
[(ngModel)]="multipleSelected"
5959
(selectionChange)="onSelectionChange($event)"
6060
>

packages/components/list/list-selection.component.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,8 @@ export class KbqListSelection
465465
}
466466
}
467467

468-
onKeyDown(event: KeyboardEvent) {
468+
/** Handles keydown events on the list. */
469+
onKeyDown(event: KeyboardEvent): void {
469470
const keyCode = event.keyCode;
470471

471472
if ([SPACE, ENTER, LEFT_ARROW, RIGHT_ARROW].includes(keyCode) || isVerticalMovement(event)) {
@@ -508,7 +509,8 @@ export class KbqListSelection
508509
this.setSelectedOptionsByKey(
509510
this.keyManager.activeItem as KbqListOption,
510511
hasModifierKey(event, 'shiftKey'),
511-
hasModifierKey(event, 'ctrlKey')
512+
// ctrlKey is for Windows, metaKey is for MacOS
513+
hasModifierKey(event, 'ctrlKey') || hasModifierKey(event, 'metaKey')
512514
);
513515
}
514516
}
@@ -825,15 +827,17 @@ export class KbqListOption implements OnDestroy, OnInit, IFocusableOption, KbqTi
825827
return clientRects.length ? clientRects[0].height : 0;
826828
}
827829

828-
handleClick($event) {
830+
/** Handles click events on the list option. */
831+
handleClick($event: MouseEvent): void {
829832
if (this.disabled) {
830833
return;
831834
}
832835

833836
this.listSelection.setSelectedOptionsByClick(
834837
this,
835838
hasModifierKey($event, 'shiftKey'),
836-
hasModifierKey($event, 'ctrlKey')
839+
// ctrlKey is for Windows, metaKey is for MacOS
840+
hasModifierKey($event, 'ctrlKey') || hasModifierKey($event, 'metaKey')
837841
);
838842
}
839843

tools/public_api_guard/components/list.api.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ export class KbqListOption implements OnDestroy, OnInit, IFocusableOption, KbqTi
109109
getLabel(): any;
110110
// (undocumented)
111111
readonly group: KbqOptgroup;
112-
// (undocumented)
113-
handleClick($event: any): void;
112+
handleClick($event: MouseEvent): void;
114113
// (undocumented)
115114
hasFocus: boolean;
116115
// (undocumented)
@@ -215,7 +214,6 @@ export class KbqListSelection extends KbqListSelectionMixinBase implements CanDi
215214
set noUnselectLast(value: boolean);
216215
// (undocumented)
217216
readonly onCopy: EventEmitter<KbqListCopyEvent<KbqListOption>>;
218-
// (undocumented)
219217
onKeyDown(event: KeyboardEvent): void;
220218
// (undocumented)
221219
readonly onSelectAll: EventEmitter<KbqListSelectAllEvent<KbqListOption>>;

0 commit comments

Comments
 (0)