Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(combobox): stop event propagation on option click (backport to 16.x) #1547

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion projects/angular/clarity.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2955,7 +2955,7 @@ export class ClrOption<T> implements OnInit {
// (undocumented)
ngOnInit(): void;
// (undocumented)
onClick(): void;
onClick(event: MouseEvent): void;
// (undocumented)
get optionId(): string;
set optionId(id: string);
Expand Down
2 changes: 1 addition & 1 deletion projects/angular/src/forms/combobox/option.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default function (): void {
it('calls to update the selection when an option is clicked', () => {
spyOn(optionSelectionService, 'select');

context.clarityDirective.onClick();
context.clarityDirective.elRef.nativeElement.click();

expect(optionSelectionService.select).toHaveBeenCalled();
});
Expand Down
5 changes: 3 additions & 2 deletions projects/angular/src/forms/combobox/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ export class ClrOption<T> implements OnInit {
}
}

@HostListener('click')
onClick() {
@HostListener('click', ['$event'])
onClick(event: MouseEvent) {
event.stopPropagation();
if (this.optionSelectionService.multiselectable) {
this.optionSelectionService.toggle(this.value);
} else {
Expand Down
Loading