Skip to content

Commit

Permalink
[Textarea] Add back defensive branch logic (#12406)
Browse files Browse the repository at this point in the history
* [Textarea] demonstrate shallow rendering test failure

Removes `disableLifecycleMethods` option from shallow render test to demonstrate the test failures that occur when that option is not set.

* [Textarea] fix shallow rendering test failures

Fixes shallow rendering test failures by adding the defensive branch logic back, along with a comment.

* save few bytes
  • Loading branch information
kanzelm3 authored and oliviertassinari committed Aug 4, 2018
1 parent cbc6828 commit 093c13e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = [
name: 'The size of all the modules of material-ui.',
webpack: true,
path: 'packages/material-ui/build/index.js',
limit: '95.7 KB',
limit: '95.8 KB',
},
{
name: 'The main bundle of the docs',
Expand Down
7 changes: 7 additions & 0 deletions packages/material-ui/src/Input/Textarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ class Textarea extends React.Component {
syncHeightWithShadow() {
const props = this.props;

// Guarding for **broken** shallow rendering method that call componentDidMount
// but doesn't handle refs correctly.
// To remove once the shallow rendering has been fixed.
if (!this.shadowRef) {
return;
}

if (this.isControlled) {
// The component is controlled, we need to update the shallow value.
this.shadowRef.value = props.value == null ? '' : String(props.value);
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Input/Textarea.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('<Textarea />', () => {
let mount;

before(() => {
shallow = createShallow({ disableLifecycleMethods: true });
shallow = createShallow();
mount = createMount();
});

Expand Down

0 comments on commit 093c13e

Please sign in to comment.