Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextField MultiLine Doesn't Work When ForceRederTabPanel Is Set To True In React-Tabs #14181

Closed
2 tasks done
vigneshrangaraj opened this issue Jan 14, 2019 · 4 comments
Closed
2 tasks done
Labels
bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@vigneshrangaraj
Copy link

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Problem Description

MultiLine feature for TextField doesn't show up until the component is clicked on or hovered over. This is happening because I set forceRenderTabPanel to true and the component is initially hidden on load. If the component loads first, this doesn't happen.

Link to minimal working code

https://codesandbox.io/s/v8jqjmylw7

Versions

Material-UI: 3.8.3
React-tabs: 3.0.0
React: 16.3.2
Browser: Chrome

@joshwooding
Copy link
Member

This is caused by the same problem as #14077 but replicated by the hidden tab instead of React Suspense.

@oliviertassinari
Copy link
Member

I have built a simpler reproduction: https://codesandbox.io/s/q8qx41qo2w.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 15, 2019

As suggested by @joshwooding, using the IntersectionObserver API, when available (IE 11 and Safari are problematic), is a viable option: https://jsfiddle.net/elmarj/u35tez5n/5/.

Now, we have to solve the same problem with server-side rendering where we can't read the DOM layout values. I think that we start with a simple fix like this:

--- a/packages/material-ui/src/InputBase/Textarea.js
+++ b/packages/material-ui/src/InputBase/Textarea.js
@@ -115,7 +115,11 @@ class Textarea extends React.Component {
       this.shadowRef.value = props.value == null ? '' : String(props.value);
     }

-    const lineHeight = this.singlelineShadowRef.scrollHeight;
+    let lineHeight = this.singlelineShadowRef.scrollHeight;
+    // The Textarea might not be visible (display: none).
+    // In this case, the layout values read from the DOM will be 0.
+    lineHeight = lineHeight === 0 ? ROWS_HEIGHT : lineHeight
+
     let newHeight = this.shadowRef.scrollHeight;

     // Guarding for jsdom, where scrollHeight isn't present.

@oliviertassinari oliviertassinari added good first issue Great for first contributions. Enable to learn the contribution process. component: text field This is the name of the generic UI component, not the React module! bug 🐛 Something doesn't work labels Jan 15, 2019
@vigneshrangaraj
Copy link
Author

I have built a simpler reproduction: https://codesandbox.io/s/q8qx41qo2w.

Thank you for this. Didn't know it was a generic visibility issue. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

No branches or pull requests

3 participants