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

Height of multiline textfield "jumps around" when element is created outside of DOM #250

Open
evertheylen opened this issue Aug 5, 2023 · 1 comment

Comments

@evertheylen
Copy link

In my app I create components outside of the DOM sometimes, only inserting them into the DOM when necessary. This seems to collide with the logic behind <Textfield multiline/>. More specifically, the textfield's height is way too small, and then jumps to the desired height.

Here is a minimal demo: https://stackblitz.com/edit/tz3p3n?file=src%2FApp.tsx

I believe this code has something to do with it:

if (computedStyle.width === "0px") {
  return;
}

If the element is not inserted into the DOM yet, it appears that all attributes of computedStyle are empty strings. Changing the code to the following helps a bit:

if (computedStyle.width === "0px" || computedStyle.width === "") {
  return;
}

But now the textfield seems to jump from slightly more than the desired height to the actual desired height, still giving a jarring user experience.

@evertheylen
Copy link
Author

(As a workaround, I'm currently using InputProps={{style: "min-height: 1234px"}} where 1234px is the height of the element after it "jumped" and has the correct height. Of course, this is rather brittle.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants