Просмотр исходного кода

reset comment height when empty

GitOrigin-RevId: 8f4144354dd2fc9f2070e0ef7955f318aaece502
Ersun Warncke 6 лет назад
Родитель
Сommit
9a252b6629
1 измененных файлов с 7 добавлено и 3 удалено
  1. 7 3
      services/web/frontend/js/directives/expandableTextArea.js

+ 7 - 3
services/web/frontend/js/directives/expandableTextArea.js

@@ -15,10 +15,14 @@ define(['base'], App =>
       const resetHeight = function() {
         const curHeight = el.outerHeight()
         const fitHeight = el.prop('scrollHeight')
-
-        if (fitHeight > curHeight && el.val() !== '') {
+        // clear height if text area is empty
+        if (el.val() === '') {
+          el.css('height', 'unset')
+        }
+        // otherwise expand to fit text
+        else if (fitHeight > curHeight) {
           scope.$emit('expandable-text-area:resize')
-          return el.css('height', fitHeight)
+          el.css('height', fitHeight)
         }
       }