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 #12878

Merged
merged 3 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
25 changes: 16 additions & 9 deletions libs/core/list/list-item/list-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ export class ListItemComponent<T = any> extends ListFocusItem<T> implements Afte
@Input()
id: Nullable<string> = 'fd-list-item-' + ++listItemUniqueId;

/** 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 Implementation of KeyboardSupportItemInterface | TODO Revisit KeyboardSupportItemInterface*/
@Output()
keyDown: EventEmitter<KeyboardEvent> = new EventEmitter<KeyboardEvent>();
Expand Down Expand Up @@ -229,16 +234,18 @@ export class ListItemComponent<T = any> extends ListFocusItem<T> implements Afte
/** 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 @@ -59,6 +59,7 @@ <h4 fd-title [headerSize]="4">
@for (item of _filteredColumns; track _filterByColumnKy($index, item)) {
<li
fd-list-item
[preventClick]="true"
[class.fd-select-item--selected]="item.selected"
[selected]="item.selected"
[class.fd-select-item--active]="item.active"
Expand Down
Loading