Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit b4d5158

Browse files
jhogervorstarschmitz
authored andcommitted
Autogrow: adds padding omitted from clientHeight by Firefox. Fixes #6179 - Textinput: height not correctly calculated in Firefox
1 parent 4692895 commit b4d5158

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

js/widgets/forms/autogrow.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,30 @@ define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", ".
5858

5959
_updateHeight:function() {
6060

61-
this.element.css( "height", "auto" );
61+
this.element.css( "height", "0px" );
6262

63-
var scrollHeight = this.element[0].scrollHeight,
63+
var paddingTop, paddingBottom, paddingHeight,
64+
scrollHeight = this.element[ 0 ].scrollHeight,
65+
clientHeight = this.element[ 0 ].clientHeight,
6466
borderTop = parseFloat( this.element.css( "border-top-width" ) ),
6567
borderBottom = parseFloat( this.element.css( "border-bottom-width" ) ),
6668
borderHeight = borderTop + borderBottom,
6769
height = scrollHeight + borderHeight + 15;
6870

71+
// Issue 6179: Padding is not included in scrollHeight and
72+
// clientHeight by Firefox if no scrollbar is visible. Because
73+
// textareas use the border-box box-sizing model, padding should be
74+
// included in the new (assigned) height. Because the height is set
75+
// to 0, clientHeight == 0 in Firefox. Therefore, we can use this to
76+
// check if padding must be added.
77+
if ( clientHeight === 0 ) {
78+
paddingTop = parseFloat( this.element.css( "padding-top" ) );
79+
paddingBottom = parseFloat( this.element.css( "padding-bottom" ) );
80+
paddingHeight = paddingTop + paddingBottom;
81+
82+
height += paddingHeight;
83+
}
84+
6985
this.element.css( "height", height + "px" );
7086
},
7187

0 commit comments

Comments
 (0)