Skip to content

Commit b165093

Browse files
committed
Fixes the auto size calc for multiinput fields.
1 parent 6c95aca commit b165093

3 files changed

Lines changed: 13 additions & 6 deletions

File tree

public/cui.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48612,7 +48612,7 @@ CUI.Input = (function(superClass) {
4861248612
this.__input.style.setProperty("--textarea-min-rows", this._min_rows);
4861348613
resize = (function(_this) {
4861448614
return function() {
48615-
var measureValue, neededRows, originalHeight, originalOverflow, originalValue;
48615+
var contentHeight, measureValue, neededRows, originalHeight, originalOverflow, originalValue;
4861648616
if (!_this.__lineHeight) {
4861748617
return;
4861848618
}
@@ -48628,7 +48628,8 @@ CUI.Input = (function(superClass) {
4862848628
_this.__input.style.overflow = "hidden";
4862948629
_this.__input.rows = 1;
4863048630
_this.__input.value = measureValue;
48631-
neededRows = Math.max(_this._min_rows, Math.ceil(_this.__input.scrollHeight / _this.__lineHeight));
48631+
contentHeight = _this.__input.scrollHeight - (_this.__verticalPadding || 0);
48632+
neededRows = Math.max(_this._min_rows, Math.ceil(contentHeight / _this.__lineHeight));
4863248633
_this.__input.rows = neededRows;
4863348634
_this.__input.value = originalValue;
4863448635
_this.__input.style.height = originalHeight;
@@ -48648,10 +48649,13 @@ CUI.Input = (function(superClass) {
4864848649
node: this.__input
4864948650
}).done((function(_this) {
4865048651
return function() {
48652+
var style;
4865148653
if (_this.isDestroyed()) {
4865248654
return;
4865348655
}
48654-
_this.__lineHeight = parseInt(CUI.dom.getComputedStyle(_this.__input).lineHeight, 10);
48656+
style = CUI.dom.getComputedStyle(_this.__input);
48657+
_this.__lineHeight = parseInt(style.lineHeight, 10);
48658+
_this.__verticalPadding = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom);
4865548659
return resize();
4865648660
};
4865748661
})(this));

public/cui.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/elements/Input/Input.coffee

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ class CUI.Input extends CUI.DataFieldInput
274274
@__input.style.overflow = "hidden"
275275
@__input.rows = 1
276276
@__input.value = measureValue
277-
neededRows = Math.max(@_min_rows, Math.ceil(@__input.scrollHeight / @__lineHeight))
277+
contentHeight = @__input.scrollHeight - (@__verticalPadding or 0)
278+
neededRows = Math.max(@_min_rows, Math.ceil(contentHeight / @__lineHeight))
278279
@__input.rows = neededRows
279280
@__input.value = originalValue
280281
@__input.style.height = originalHeight
@@ -292,7 +293,9 @@ class CUI.Input extends CUI.DataFieldInput
292293
CUI.dom.waitForDOMInsert(node: @__input).done(=>
293294
if @isDestroyed()
294295
return
295-
@__lineHeight = parseInt(CUI.dom.getComputedStyle(@__input).lineHeight, 10)
296+
style = CUI.dom.getComputedStyle(@__input)
297+
@__lineHeight = parseInt(style.lineHeight, 10)
298+
@__verticalPadding = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)
296299
resize()
297300
)
298301
else

0 commit comments

Comments
 (0)