qontu / ngx-inline-editor

Native UI Inline-editor Angular (4.0+) component
https://qontu.github.io/ngx-inline-editor
MIT License
164 stars 90 forks source link

Input's value is changed when clicking cancel button #78

Closed ManuelMolina97 closed 7 years ago

ManuelMolina97 commented 7 years ago

Running this piece of code:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
  <h1> {{editableText}} </h1>
    <div>
        <inline-editor 
          type="text" 
          [(ngModel)]="editableText" 
          (onSave)="saveEditable($event)" 
          (onBlur)="saveEditable($event)"
          [onlyValue]="false"
          [hideButtons]="false"
          [saveOnBlur]="true">
        </inline-editor>
    </div>
  `
})
export class AppComponent {
  editableText = true;

  saveEditable(event) {
    console.log(event);
  }
}

Input's value gets changed does not matter whether I click its cancel button or its confirm button.

tonivj5 commented 7 years ago

Thanks for your report! This bug has priority

ManuelMolina97 commented 7 years ago

I just realized of my mistake, the problem was I had:

[saveOnBlur]="true"

In my template, so blur event was triggered before cancel's. That's why it was being saved.

tonivj5 commented 7 years ago

Thanks for share your experience! 🤣