This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/expanding-text-area.js.es6
2019-11-07 15:38:28 -06:00

27 lines
681 B
JavaScript

import { scheduleOnce } from "@ember/runloop";
import { on, observes } from "discourse-common/utils/decorators";
import autosize from "discourse/lib/autosize";
export default Ember.TextArea.extend({
@on("didInsertElement")
_startWatching() {
scheduleOnce("afterRender", () => {
$(this.element).focus();
autosize(this.element);
});
},
@observes("value")
_updateAutosize() {
this.element.value = this.value;
const evt = document.createEvent("Event");
evt.initEvent("autosize:update", true, false);
this.element.dispatchEvent(evt);
},
@on("willDestroyElement")
_disableAutosize() {
autosize.destroy($(this.element));
}
});