Skip to content

Commit

Permalink
Fixed #11025 - TableHeaderCheckbox is checked when the selection arra…
Browse files Browse the repository at this point in the history
…y is empty
  • Loading branch information
mertsincan committed Jan 3, 2022
1 parent 8e60cc4 commit 08a54d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app/components/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4087,7 +4087,7 @@ export class TableHeaderCheckbox {
const val = this.dt.frozenValue ? [...this.dt.frozenValue, ...data] : data;
const selectableVal = this.dt.rowSelectable ? val.filter((data, index) => this.dt.rowSelectable({ data, index })) : val;

return selectableVal && this.dt.selection && selectableVal.every(v => this.dt.selection.some(s => this.dt.equals(v, s)));
return ObjectUtils.isNotEmpty(selectableVal) && ObjectUtils.isNotEmpty(this.dt.selection) && selectableVal.every(v => this.dt.selection.some(s => this.dt.equals(v, s)));
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/app/components/utils/objectutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,17 @@ export class ObjectUtils {
}

return str;
}
}

public static isEmpty(value) {
return (
value === null || value === undefined || value === '' ||
(Array.isArray(value) && value.length === 0) ||
(!(value instanceof Date) && typeof value === 'object' && Object.keys(value).length === 0)
);
}

public static isNotEmpty(value) {
return !this.isEmpty(value);
}
}

0 comments on commit 08a54d7

Please sign in to comment.