Browse Source

New Checklistitems are now autoresized too

- also using for autoresize now:
  verron:autosize
Martin Filser 4 years ago
parent
commit
03bfd9a2b5
1 changed files with 8 additions and 8 deletions
  1. 8 8
      client/components/cards/checklists.js

+ 8 - 8
client/components/cards/checklists.js

@@ -186,12 +186,6 @@ BlazeComponent.extendComponent({
     }
   },
 
-  // resize the textarea vertically to fit the user-input
-  autoResize(event) {
-    const textarea = event.target;
-    textarea.style.height = textarea.scrollHeight + 'px';
-  },
-
   events() {
     const events = {
       'click .toggle-delete-checklist-dialog'(event) {
@@ -215,8 +209,6 @@ BlazeComponent.extendComponent({
         'click .js-delete-checklist-item': this.deleteItem,
         'click .confirm-checklist-delete': this.deleteChecklist,
         'focus .js-add-checklist-item': this.focusChecklistItem,
-        'input textarea.js-edit-checklist-item': this.autoResize,
-        'focus textarea.js-edit-checklist-item': this.autoResize,
         keydown: this.pressKey,
       },
     ];
@@ -231,6 +223,14 @@ Template.checklists.helpers({
   },
 });
 
+Template.addChecklistItemForm.onRendered(() => {
+  autosize($('textarea.js-add-checklist-item'))
+});
+
+Template.editChecklistItemForm.onRendered(() => {
+  autosize($('textarea.js-edit-checklist-item'))
+});
+
 Template.checklistDeleteDialog.onCreated(() => {
   const $cardDetails = this.$('.card-details');
   this.scrollState = {