From efbd414a4d5af7b5144f1d08522e46cc043b627d Mon Sep 17 00:00:00 2001 From: Robert Messerle Date: Thu, 19 Feb 2015 14:18:54 -0800 Subject: [PATCH] fix(input): fix hidden textarea height issue Closes #1356. --- src/components/input/input.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/input/input.js b/src/components/input/input.js index 4bbb30b553b..ec340e2e46c 100644 --- a/src/components/input/input.js +++ b/src/components/input/input.js @@ -241,10 +241,14 @@ function inputTextareaDirective($mdUtil, $window) { function growTextarea() { node.style.height = "auto"; - var line = node.scrollHeight - node.offsetHeight; node.scrollTop = 0; - var height = node.offsetHeight + (line > 0 ? line : 0); - node.style.height = height + 'px'; + var height = getHeight(); + if (height) node.style.height = height + 'px'; + } + + function getHeight () { + var line = node.scrollHeight - node.offsetHeight; + return node.offsetHeight + (line > 0 ? line : 0); } function onScroll(e) {