Socket
Socket
Sign inDemoInstall

react-textarea-autosize

Package Overview
Dependencies
Maintainers
2
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-textarea-autosize - npm Package Compare versions

Comparing version 2.2.3 to 2.3.0

23

lib/calculateNodeHeight.js

@@ -34,3 +34,3 @@ 'use strict';

var sizingStyle = _calculateNodeStyling.sizingStyle;
var sumVerticalPaddings = _calculateNodeStyling.sumVerticalPaddings;
var heightAdjustment = _calculateNodeStyling.heightAdjustment;

@@ -43,3 +43,3 @@ // Need to have the overflow attribute to hide the scrollbar otherwise

hiddenTextarea.value = uiTextNode.value;
var height = hiddenTextarea.scrollHeight - sumVerticalPaddings;
var height = hiddenTextarea.scrollHeight + heightAdjustment;
var minHeight = -Infinity;

@@ -51,3 +51,3 @@ var maxHeight = Infinity;

hiddenTextarea.value = 'x';
var singleRowHeight = hiddenTextarea.scrollHeight - sumVerticalPaddings;
var singleRowHeight = hiddenTextarea.scrollHeight + heightAdjustment;
if (minRows !== null) {

@@ -76,8 +76,13 @@ minHeight = singleRowHeight * minRows;

var sumPaddings = 0;
// scrollHeight = content + padding; depending on what box-sizing is
// set to, we'll need an adjustment when we set the new height
var heightAdjustment = 0;
// If the textarea is set to border-box, it's not necessary to
// subtract the padding.
if (compStyle.getPropertyValue('box-sizing') !== 'border-box' && compStyle.getPropertyValue('-moz-box-sizing') !== 'border-box' && compStyle.getPropertyValue('-webkit-box-sizing') !== 'border-box') {
sumPaddings = parseFloat(compStyle.getPropertyValue('padding-bottom')) + parseFloat(compStyle.getPropertyValue('padding-top'));
var boxSizing = compStyle.getPropertyValue('box-sizing') || compStyle.getPropertyValue('-moz-box-sizing') || compStyle.getPropertyValue('-webkit-box-sizing');
// border-box: add border, since height = content + padding + border
if (boxSizing === 'border-box') {
heightAdjustment = parseFloat(compStyle.getPropertyValue('border-bottom')) + parseFloat(compStyle.getPropertyValue('border-top'));
} else if (boxSizing === 'content-box') {
// remove padding, since height = content
heightAdjustment = -(parseFloat(compStyle.getPropertyValue('padding-bottom')) + parseFloat(compStyle.getPropertyValue('padding-top')));
}

@@ -89,3 +94,3 @@

}).join(';'),
sumVerticalPaddings: sumPaddings
heightAdjustment: heightAdjustment
};

@@ -92,0 +97,0 @@

{
"name": "react-textarea-autosize",
"description": "textarea component for React which grows with content",
"version": "2.2.3",
"version": "2.3.0",
"author": {

@@ -6,0 +6,0 @@ "name": "Andrey Popp",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc