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

[Input] placeholder should be displayed if InputLabel is shrinked #8436

Closed
1 task done
Floriferous opened this issue Sep 28, 2017 · 5 comments
Closed
1 task done

[Input] placeholder should be displayed if InputLabel is shrinked #8436

Floriferous opened this issue Sep 28, 2017 · 5 comments
Assignees
Labels
bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module!

Comments

@Floriferous
Copy link
Contributor

When composing a textfield with FormControl, InputLabel and Input. The placeholder is hidden even when shrink is set to true on InputLabel. #7821

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

Expected Behavior

Composing an input like this:

<FormControl >
  <InputLabel htmlFor="my-input" shrink>
    The label
  </InputLabel>
  <Input
    id="my-input"
    placeholder="Placeholder"
  />
</FormControl>

Should display a placeholder at all times, like a regular input (except with content in it).

Current Behavior

The placeholder is only shown on focus.

Context

I am personally not a fan of material-ui's label animation, it confuses our users, and it's not clear to them that this is an input where they can type something.

Your Environment

Tech Version
Material-UI next

An attempt at a solution could use the suggestion by @robert-figshare. Adding this sort of css to the Input component (not sure how to apply the JSS shrink class):

input: {
  'label.shrink + $formControl &': {
    placeholder: { opacity: 0.5 }
  },
},
@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module! v1 labels Sep 28, 2017
@oliviertassinari
Copy link
Member

@Floriferous Thanks for posting a detail issue! I can have a look at it.

@rickAllDev
Copy link

Was just struggling with this issue and stumbled upon this discussion. I realize that the issue is closed and assume that the ability to show placeholder without input having the focus is now available? Could you please point me to some documentation on how to implement.

@GarrettJMU
Copy link

Also experiencing this issue.

@lxblvs
Copy link

lxblvs commented Sep 9, 2018

All right. This has been bothering me for a few hours so I had to DIG.
The first clue that something is wrong was this shadow DOM:
image
Looks like even with the data-shink=false we still hide the placeholder by opacity: 0

Lines 138:141 in the Input.js seem to be the culprits as the value should be placeholderVisible instead of placeholderHidden.

A fast fix for local versions is:

inputRoot: {
        'label[data-shrink=false] + & ::-webkit-input-placeholder': {
            opacity: '0.5 !important',
        },
}

@rj-wowza
Copy link

a few years later, i had to do the following with ThemeProvider

MuiInputBase: {
  styleOverrides: {
    root: {
    // restore hidden placeholder
    formControl: {
      'label[data-shrink=false].MuiFormLabel-root ~ & ::-webkit-input-placeholder': {
        opacity: '0.5!important',
      },
    }
  }
},

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!
Projects
None yet
Development

No branches or pull requests

6 participants