From 43ed43a5bf2c9cbb428447cc0223b3a7123cc6f0 Mon Sep 17 00:00:00 2001 From: JoaoBianco Date: Fri, 26 Apr 2024 15:36:22 -0300 Subject: [PATCH 1/2] Verify select options on init --- .../sq-select-multi-tags.component.ts | 11 +++++++++-- src/package.json | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/sq-select-multi-tags/sq-select-multi-tags.component.ts b/src/components/sq-select-multi-tags/sq-select-multi-tags.component.ts index 1309aa4..5c58d8a 100644 --- a/src/components/sq-select-multi-tags/sq-select-multi-tags.component.ts +++ b/src/components/sq-select-multi-tags/sq-select-multi-tags.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnChanges, Optional, Output, SimpleChanges, TrackByFunction } from '@angular/core' +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnChanges, Optional, Output, SimpleChanges, TrackByFunction, OnInit } from '@angular/core' import { TranslateService } from '@ngx-translate/core' import { OptionMulti } from '../../interfaces/option.interface' import { useMemo } from '../../helpers/memo.helper' @@ -24,7 +24,7 @@ import { useMemo } from '../../helpers/memo.helper' styleUrls: ['./sq-select-multi-tags.component.scss'], providers: [], }) -export class SqSelectMultiTagsComponent implements OnChanges { +export class SqSelectMultiTagsComponent implements OnChanges, OnInit { /** * The name attribute for the multi-tag select input. * @@ -290,6 +290,13 @@ export class SqSelectMultiTagsComponent implements OnChanges { } } + /** + * Lifecycle hook called after the view initialization to validate pre-selected values. + */ + async ngOnInit() { + this.validate() + } + /** * Determines if an item exists in the selected values. * diff --git a/src/package.json b/src/package.json index 68809cd..cadf11b 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "@squidit/ngx-css", - "version": "1.3.28", + "version": "1.3.29", "peerDependencies": { "@angular/common": ">=15.0.0", "@angular/core": ">=15.0.0", From e48e95f82787c3301fb28a33157ea57e6ffdb791 Mon Sep 17 00:00:00 2001 From: JoaoBianco Date: Fri, 26 Apr 2024 16:08:32 -0300 Subject: [PATCH 2/2] Change to onChanges --- .../sq-select-multi-tags.component.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/components/sq-select-multi-tags/sq-select-multi-tags.component.ts b/src/components/sq-select-multi-tags/sq-select-multi-tags.component.ts index 5c58d8a..1b46c75 100644 --- a/src/components/sq-select-multi-tags/sq-select-multi-tags.component.ts +++ b/src/components/sq-select-multi-tags/sq-select-multi-tags.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnChanges, Optional, Output, SimpleChanges, TrackByFunction, OnInit } from '@angular/core' +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnChanges, Optional, Output, SimpleChanges, TrackByFunction } from '@angular/core' import { TranslateService } from '@ngx-translate/core' import { OptionMulti } from '../../interfaces/option.interface' import { useMemo } from '../../helpers/memo.helper' @@ -24,7 +24,7 @@ import { useMemo } from '../../helpers/memo.helper' styleUrls: ['./sq-select-multi-tags.component.scss'], providers: [], }) -export class SqSelectMultiTagsComponent implements OnChanges, OnInit { +export class SqSelectMultiTagsComponent implements OnChanges { /** * The name attribute for the multi-tag select input. * @@ -288,13 +288,9 @@ export class SqSelectMultiTagsComponent implements OnChanges, OnInit { if (this.open && changes.hasOwnProperty('options')) { this.addMoreOptions(true) } - } - - /** - * Lifecycle hook called after the view initialization to validate pre-selected values. - */ - async ngOnInit() { - this.validate() + if (changes.hasOwnProperty('value') || changes.hasOwnProperty('minTags') || changes.hasOwnProperty('maxTags')) { + this.validate() + } } /**