Skip to content

Commit

Permalink
Fix useMemo change catch
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasPeres committed Nov 23, 2023
1 parent c5ac308 commit e137089
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@
[name]="name + '-checkbox'"
[value]="opt?.value"
[disabled]="opt?.disabled"
[checked]="findItemInValue(opt)"
[indeterminate]="verifyIfHasChildrenInValue(opt)"
[checked]="findItemInValue(opt, value)"
[indeterminate]="verifyIfHasChildrenInValue(opt, value)"
(valueChange)="emit(opt, $event.checked)"
></sq-selector>
<span class="text m-0 display-inline-block" [ngClass]="{ 'cursor-pointer': opt?.children?.length }" (click)="handleCollapse(opt)">{{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ export class SqSelectMultiTagsComponent implements OnChanges {
* @param {OptionMulti} item - The item to search for.
* @returns {boolean} True if the item exists in the selected values; otherwise, false.
*/
findItemInValue = useMemo((item: OptionMulti) => {
return !!this.value?.find((value) => value.value === item.value)
findItemInValue = useMemo((item: OptionMulti, value?: Array<OptionMulti>) => {
return !!value?.find((value) => value.value === item.value)
})

/**
Expand All @@ -311,17 +311,17 @@ export class SqSelectMultiTagsComponent implements OnChanges {
* @param {OptionMulti} item - The item to check.
* @returns {boolean} True if the item has selected children; otherwise, false.
*/
verifyIfHasChildrenInValue = useMemo((item: OptionMulti) => {
verifyIfHasChildrenInValue = useMemo((item: OptionMulti, value?: Array<OptionMulti>) => {
if (item.children?.length) {
const hasAllChildren = item.children.every((child) => this.findItemInValue(child))
if (hasAllChildren && !this.findItemInValue(item) && !this.timeouted) {
const hasAllChildren = item.children.every((child) => this.findItemInValue(child, value))
if (hasAllChildren && !this.findItemInValue(item, value) && !this.timeouted) {
this.timeouted = true
setTimeout(() => {
this.emit(item, true)
this.timeouted = false
}, 0)
}
return !!item.children.find((child) => this.findItemInValue(child))
return !!item.children.find((child) => this.findItemInValue(child, value))
}
return false
})
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@squidit/ngx-css",
"version": "1.2.01",
"version": "1.2.1",
"peerDependencies": {
"@angular/common": ">=15.0.0",
"@angular/core": ">=15.0.0",
Expand Down

0 comments on commit e137089

Please sign in to comment.