Ghost/ghost/admin/app/components/gh-trim-focus-input.js
Gabriel Csapo 8d01fb5556 Switched majority of files from EmberObject to native class syntax using @classic decorator (#2227)
no issue

- ran [ember-native-class-codemod](https://github.com/ember-codemods/ember-native-class-codemod) to convert the majority of remaining EmberObject based controllers and components to native class syntax using the `@classic` decorator
- skipped older style modal components (`components/modal-*.js`) due to observed incompatibilities in some cases
2022-02-01 09:34:03 +00:00

35 lines
881 B
JavaScript

import GhostTextInput from 'ghost-admin/components/gh-text-input';
import classic from 'ember-classic-decorator';
/**
* This doesn't override the OneWayInput component because
* we need finer control. It borrows
* parts from both the OneWayInput component and Ember's default
* input component
*/
@classic
class TrimFocusInputComponent extends GhostTextInput {
shouldFocus = true;
focusOut(event) {
this._trimInput(event.target.value, event);
super.focusOut(...arguments);
}
_trimInput(value, event) {
if (value && typeof value.trim === 'function') {
value = value.trim();
}
this.element.value = value;
this._elementValueDidChange(event);
let inputMethod = this.input;
if (inputMethod) {
inputMethod(event);
}
}
}
export default TrimFocusInputComponent;