Skip to content

Commit

Permalink
fix(dropdown): prevent activating disabled dropdown item via keyboard
Browse files Browse the repository at this point in the history
closes #389
  • Loading branch information
kevinbuhmann committed Dec 14, 2022
1 parent 85df471 commit 1481ce1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions projects/angular/src/popover/dropdown/dropdown-item.ts
Expand Up @@ -76,4 +76,20 @@ export class ClrDropdownItem {
}
});
}

@HostListener('keydown.space', ['$event'])
private onSpaceKeydown($event: KeyboardEvent) {
this.stopImmediatePropagationIfDisabled($event);
}

@HostListener('keydown.enter', ['$event'])
private onEnterKeydown($event: KeyboardEvent) {
this.stopImmediatePropagationIfDisabled($event);
}

private stopImmediatePropagationIfDisabled($event: Event) {
if (this.disabled) {
$event.stopImmediatePropagation();
}
}
}

0 comments on commit 1481ce1

Please sign in to comment.