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(core,platform): clicking list item in p13 dialog should not toggle checkbox #12879

Merged
merged 2 commits into from
Jan 8, 2025
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
27 changes: 18 additions & 9 deletions libs/core/src/lib/list/list-item/list-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ export class ListItemComponent<T = any>
@Input()
ariaRole: Nullable<string>;

/**
* Whether to prevent built-in click event logic on the list item.
* Helpful when using lists with checkboxes or radio buttons when the list item should be clickable, but should not select/deselect the list item.
*/
@Input()
preventClick = false;

/** @hidden */
@ContentChild(FD_RADIO_BUTTON_COMPONENT)
set radio(value: RadioButtonComponent) {
Expand Down Expand Up @@ -265,16 +272,18 @@ export class ListItemComponent<T = any>
/** Handler for mouse events */
@HostListener('click', ['$event'])
onClick(event: MouseEvent): void {
this._clicked$.next(event);
if (this.checkbox && !this.link) {
if (!this.checkbox.elementRef.nativeElement.contains(event.target as Node)) {
// clicking on the checkbox is not suppressed
// so we should only process clicks if clicked on the list-item, not checkbox itself
this.checkbox.nextValue();
if (!this.preventClick) {
this._clicked$.next(event);
if (this.checkbox && !this.link) {
if (!this.checkbox.elementRef.nativeElement.contains(event.target as Node)) {
// clicking on the checkbox is not suppressed
// so we should only process clicks if clicked on the list-item, not checkbox itself
this.checkbox.nextValue();
}
}
if (this.radio && !this.link) {
this.radio.labelClicked(event, false);
}
}
if (this.radio && !this.link) {
this.radio.labelClicked(event, false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ <h4 fd-title [headerSize]="4">
[class.fd-select-item--active]="item.active"
[selected]="item.selected"
(focus)="_setActiveColumn(item)"
[preventClick]="true"
>
<fd-checkbox [(ngModel)]="item.selected" (ngModelChange)="_onToggleColumn()"></fd-checkbox>
<span fd-list-title>
Expand Down
Loading