Fix max-height in select input when value is null

This commit is contained in:
Konstantinos Triantafyllou 2022-03-28 12:14:16 +03:00
parent 99ed7ea6ba
commit d2a05db2e3
1 changed files with 5 additions and 2 deletions

View File

@ -15,7 +15,6 @@ import {
import {AbstractControl, FormArray, FormControl, ValidatorFn} from "@angular/forms"; import {AbstractControl, FormArray, FormControl, ValidatorFn} from "@angular/forms";
import {HelperFunctions} from "../../utils/HelperFunctions.class"; import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {Observable, of, Subscription} from "rxjs"; import {Observable, of, Subscription} from "rxjs";
import {MatSelect} from "@angular/material/select";
import {MatAutocompleteSelectedEvent} from "@angular/material/autocomplete"; import {MatAutocompleteSelectedEvent} from "@angular/material/autocomplete";
import {map, startWith} from "rxjs/operators"; import {map, startWith} from "rxjs/operators";
import {MatChipInputEvent} from "@angular/material/chips"; import {MatChipInputEvent} from "@angular/material/chips";
@ -283,7 +282,9 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
ngAfterViewInit() { ngAfterViewInit() {
/** If options are available set max-height base on input-wrapper height */ /** If options are available set max-height base on input-wrapper height */
if(this.options && this.options.length > 1) { if(this.options && this.options.length > 1) {
this.elementRef.nativeElement.style.maxHeight = this.inputBox.nativeElement.clientHeight + 'px'; setTimeout(() => {
this.elementRef.nativeElement.style.maxHeight = this.inputBox.nativeElement.clientHeight + 'px';
}, 0);
} }
this.reset(); this.reset();
} }
@ -342,6 +343,8 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
} }
if (this.initValue === value || (this.initValue === '' && value === null)) { if (this.initValue === value || (this.initValue === '' && value === null)) {
this.formControl.markAsPristine(); this.formControl.markAsPristine();
} else {
this.formControl.markAsDirty();
} }
if (this.searchControl) { if (this.searchControl) {
this.searchControl.setValue(null); this.searchControl.setValue(null);