open-consul/ui-v2/app/components/radio-group/index.js
John Cowen 41c988270f ui: Remove WithSearching mixin, use helpers instead (#7961)
* ui: Remove WithSearching mixin, use composable helpers instead
2020-06-03 16:46:53 +00:00

26 lines
618 B
JavaScript

import Component from '@ember/component';
import { inject as service } from '@ember/service';
const ENTER = 13;
export default Component.extend({
tagName: '',
keyboardAccess: false,
dom: service('dom'),
init: function() {
this._super(...arguments);
this.name = this.dom.guid(this);
},
actions: {
keydown: function(e) {
if (e.keyCode === ENTER) {
e.target.dispatchEvent(new MouseEvent('click'));
}
},
change: function(e) {
this.onchange(
this.dom.setEventTargetProperty(e, 'value', value => (value === '' ? undefined : value))
);
},
},
});