mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
8d01fb5556
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
35 lines
881 B
JavaScript
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;
|