Skip to content

Commit

Permalink
fix paper-input not clearing text
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelcobain committed Jul 25, 2019
1 parent edf651d commit f117ca0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion addon/components/paper-autocomplete-trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Component from '@ember/component';
import { not } from '@ember/object/computed';
import { computed } from '@ember/object';
import layout from '../templates/components/paper-autocomplete-trigger';
import unwrapProxy from 'ember-paper/utils/unwrap-proxy';

/**
* @class PaperAutocompleteTrigger
Expand All @@ -26,7 +27,7 @@ export default Component.extend({
}),

text: computed('select.{searchText,selected}', function() {
let selected = this.get('select.selected');
let selected = unwrapProxy(this.get('select.selected'));
if (selected) {
return this.getSelectedAsText();
}
Expand Down
2 changes: 1 addition & 1 deletion addon/components/paper-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default Component.extend(FocusableMixin, ColorMixin, ChildMixin, Validati
// normalize falsy values to empty string
value = isEmpty(value) ? '' : value;

if (this.element.querySelector('input, textarea').value !== value && value) {
if (this.element.querySelector('input, textarea').value !== value) {
this.element.querySelector('input, textarea').value = value;
}
},
Expand Down
11 changes: 11 additions & 0 deletions addon/utils/unwrap-proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import ArrayProxy from '@ember/array/proxy';
import ObjectProxy from '@ember/object/proxy';
import { get } from '@ember/object';

export default function unwrapProxy(o) {
return isProxy(o) ? unwrapProxy(get(o, 'content')) : o;
}

export function isProxy(o) {
return !!(o && (o instanceof ObjectProxy || o instanceof ArrayProxy));
}

0 comments on commit f117ca0

Please sign in to comment.