Material-ui: [TextField] Outlined renders gap with label = empty string

Created on 12 Feb 2020  路  2Comments  路  Source: mui-org/material-ui

Regression for outlined text-field with label="".

  • [x] The issue is present in the latest release.
  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 馃槸

label set to empty string

(buggy is the value)

Expected Behavior 馃


label not set

(fine is the value)

Steps to Reproduce 馃暪

https://codesandbox.io/s/trusting-snow-8ses9

Steps:

  1. Use a TextField with label=""

It works when omitting the label prop at all (or with label={undefined}).

This problem seems to occur since v4.9.0 - it works fine with prior versions!

Context 馃敠

I wanted to display the input without a label and stumbled across this.

Your Environment 馃寧

| Tech | Version |
| ----------- | ------- |
| Material-UI | v4.9.2 |
| React | |
| Browser | |
| TypeScript | |
| etc. | |

bug 馃悰 TextField good to take

Most helpful comment

I can pick it up if no body mind

All 2 comments

I think we want to stick with string => some label, undefined => no label semantics. It's simpler that way instead of separately handling empty strings. We would also need to document these because "empty string" is not obvious.

With regards to regressions: This would also apply to label={0} which doesn't make much sense at all.

To avoid churn we could special case label === "" and remove it in v5 to avoid type overloading and two-values-doing-the-same thing API issues.

I can pick it up if no body mind

Was this page helpful?
0 / 5 - 0 ratings