aupac / ember-aupac-typeahead

ember-cli ajax typeahead search component
MIT License
25 stars 38 forks source link

Backspace is deleting everything #29

Open kennethlarsen opened 7 years ago

kennethlarsen commented 7 years ago

There's an issue with {{aupac-typeahead}} where deleting a single character in the input removes the entire input value. This is very annoying for correcting typos.

This is happening when suggestions are objects (which we fetch from an api).

Basically it looks like this gets called when I press backspace this.get('_typeahead').typeahead('val', ''); (line 79 in addon/components/aupac-typeahead.js)

kennethlarsen commented 7 years ago

Basically doing some thing like:

//typeahead.js Customizations
allowCharacterDeletion: false, //@public

  setValue : function(selection) {
    selection = this.transformSelection(selection);
    if(selection) {
      this.get('_typeahead').typeahead('val', selection);
    } else if (!this.get('allowCharacterDeletion')){
      this.get('_typeahead').typeahead('val', '');
    }
  },

returns the expected behavior.

jackmatt2 commented 7 years ago

Maybe this should be the default behaviour.

jackmatt2 commented 7 years ago

This appears to be working for me. I am pretty sure this feature only works with Strings though.

jackmatt2 commented 7 years ago

Just tested with a ember-data model and it is working.

jackmatt2 commented 7 years ago

After some experimentation I can see this issue now. I have included it as part of a bigger cleanup issue.

mnifakram commented 7 years ago

Does this issue still valid? I can't reproduce it! If anyone can give a hint or twiddle on how to reproduce it. I will be happy to fix it.

jackmatt2 commented 7 years ago

@mnifakram yes, this should still be an unresolved bug.

Charizard commented 6 years ago

Happening for me in v3.0.0

GCheung55 commented 5 years ago

Happening in v3.1.0.