mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
245f4ea80e
closes https://github.com/TryGhost/Ghost/issues/8463 - move generic text input handling into `text-input` mixin so it applies to text inputs and textareas - adds `autoExpand` property to `gh-textarea` that accepts a selector to watch for resize changes, if the property is set then auto-expanding behaviour is triggered any time the textarea value is changed or when the selector element is resized (this prevents change in textarea width from toggling nav or split screen mode resulting in textarea content being hidden or the textarea being taller than it's contents) - adds `ember-element-resize-detector` addon to allow watching of element resizes rather than window resizes (this was already included as a sub-dependency via `ember-light-table`->`ember-scrollable`->`ember-element-resize-detector`)
27 lines
614 B
JavaScript
27 lines
614 B
JavaScript
import GhostInput from 'ghost-admin/components/gh-input';
|
|
|
|
/**
|
|
* 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
|
|
*/
|
|
const TrimFocusInputComponent = GhostInput.extend({
|
|
|
|
shouldFocus: true,
|
|
|
|
focusOut(event) {
|
|
this._trimInput(event.target.value);
|
|
},
|
|
|
|
_trimInput(value) {
|
|
if (value && typeof value.trim === 'function') {
|
|
value = value.trim();
|
|
}
|
|
|
|
this._processNewValue(value);
|
|
}
|
|
});
|
|
|
|
export default TrimFocusInputComponent;
|