From 726541ae08f5e5c0a8bc000f4d71bb94b2938a61 Mon Sep 17 00:00:00 2001 From: afc163 Date: Tue, 27 Jun 2017 12:03:10 +0800 Subject: [PATCH] Improve autosize textarea scrollbar style, close #6609 --- components/input/calculateNodeHeight.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/input/calculateNodeHeight.tsx b/components/input/calculateNodeHeight.tsx index e3226e570e..13fdc7d3e6 100644 --- a/components/input/calculateNodeHeight.tsx +++ b/components/input/calculateNodeHeight.tsx @@ -119,6 +119,7 @@ export default function calculateNodeHeight( let minHeight = -Infinity; let maxHeight = Infinity; let height = hiddenTextarea.scrollHeight; + let overflowY; if (boxSizing === 'border-box') { // border-box: add border, since height = content + padding + border @@ -144,8 +145,9 @@ export default function calculateNodeHeight( if (boxSizing === 'border-box') { maxHeight = maxHeight + paddingSize + borderSize; } + overflowY = height > maxHeight ? '' : 'hidden'; height = Math.min(maxHeight, height); } } - return { height, minHeight, maxHeight }; + return { height, minHeight, maxHeight, overflowY }; }