ngx chips sorting after editing the chips doesn't work in chrome but working in firefox

79 Views Asked by At

I am using ngx chips and I am trying to edit the tags after adding and called a sorting functin to sort them it's working as expected in firefox but not in chrome. is there any browser issue ?

tags.component.html

  <tag-input [id]="id" [formControlName]="fieldName" [(ngModel)]='defaultValue' class="form-control" [displayBy]="'text'" (onTagEdited)="onTextChangeInput($event)" (onAdd)="onItemAdded($event)" (onRemove)="onItemRemoved($event)"    [identifyBy]="'text'"></tag-input>

tags.component.ts

 onTextChangeInput(value:any) {
    if(this.field.defaultValue[value.index] && this.defaultValue[value.index].text){
      this.defaultValue[value.index].text = value.tag.text;
    }
    this.defaultValue = this.sortByText(defaultValue);
}

sorting function

  sortByText(data:any):any{
    let nameA:any;
    let nameB:any;
    let returnedValue:any =   data.sort((a:any, b:any) => {
      if(this.field.valueType !== 'string'){
        nameA = a.text.toUpperCase();
        nameB = b.text.toUpperCase();
      }
      else{
        nameA = a.toUpperCase();
        nameB = b.toUpperCase();
      }
      if (nameA < nameB) {
        return -1;
      }
      if (nameA > nameB) {
        return 1;
      }
      return 0;
    })
    return returnedValue;
  }

It's work as expected in firefox browser but not in chrome

0

There are 0 best solutions below