Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 1fe3857

Browse files
crisbetoThomasBurleson
authored andcommitted
fix(textarea): properly preserve the padding after measuring the line height
* Fixes the textarea not resetting the padding if the page has jQuery. * Fixes the textarea not preserving padding from an inline style. Fixes #8782. Closes #8790
1 parent 0d238dd commit 1fe3857

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/components/input/input.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,9 @@ function inputTextareaDirective($mdUtil, $window, $mdAria, $timeout, $mdGesture)
447447

448448
if (!lineHeight) {
449449
// offsetHeight includes padding which can throw off our value
450+
var originalPadding = element[0].style.padding || '';
450451
lineHeight = element.css('padding', 0).prop('offsetHeight');
451-
element.css('padding', null);
452+
element[0].style.padding = originalPadding;
452453
}
453454

454455
if (minRows && lineHeight) {

src/components/input/input.spec.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ describe('md-input-container directive', function() {
193193
expect(el).toHaveClass('md-input-has-value');
194194

195195
pageScope.$apply('value = ""');
196-
196+
197197
expect(el).not.toHaveClass('md-input-has-value');
198198
});
199199

@@ -751,6 +751,18 @@ describe('md-input-container directive', function() {
751751
createAndAppendElement('md-no-resize');
752752
expect(element.querySelector('.md-resize-handle')).toBeFalsy();
753753
});
754+
755+
it('should reset the padding after measuring the line height', function() {
756+
createAndAppendElement();
757+
ngTextarea.triggerHandler('input');
758+
expect(textarea.style.padding).toBeFalsy();
759+
});
760+
761+
it('should preserve the original inline padding', function() {
762+
createAndAppendElement('style="padding: 10px;"');
763+
ngTextarea.triggerHandler('input');
764+
expect(textarea.style.padding).toBe('10px');
765+
});
754766
});
755767

756768
describe('icons', function () {

0 commit comments

Comments
 (0)