components icon indicating copy to clipboard operation
components copied to clipboard

bug(md-input) placeholder hidden underneath input with no value

Open benb7760 opened this issue 9 years ago • 34 comments

Bug, feature request, or proposal:

Bug

What is the expected behavior?

With no value provided, the placeholder should sit in front of the input element

What is the current behavior?

The placeholder is hidden behind the input element. Selecting the element triggers the ordinary animation, moving the placeholder above the input.

What are the steps to reproduce?

http://plnkr.co/edit/VV9wDNx7FIK0gVDWsMU6?p=preview I was annoyingly unable to reproduce on Plunker. The code in that Plunker does not work on my machine. I am using the material builds repo; "@angular/material": "git+https://github.com/angular/material2-builds.git#8f246c0"

That exact commit is where the bug first appears for me. I have also tried against the main repo at beta.2 and the same issue occurs

-I can't see any specific CSS being used within my project- I have since removed all of my app content and this still happens with no custom CSS

Which versions of Angular, Material, OS, browsers are affected?

Chrome 56, Safari 10.0.3 (untested elsewhere). Material 2.0.0-beta.2 and material-builds #8f246c0

benb7760 avatar Feb 19 '17 19:02 benb7760

Update - it appears to be resolved by reverting: .mat-input-placeholder-wrapper::after content from '' back to '\00a0'

benb7760 avatar Feb 19 '17 20:02 benb7760

The issue with reverting the content back to \00a0 is that the browser can end up rendering it in some cases (AFAIK Chrome on Linux is one of them).

Also, if you're unable to reproduce it in a Plunkr, can you post a screenshot of what it looks like?

crisbeto avatar Feb 19 '17 20:02 crisbeto

Update - I have disabled all custom CSS and can confirm that this still happens.

No selection image

Selection image

benb7760 avatar Feb 19 '17 21:02 benb7760

Hmm that's weird. What OS and browser are you using?

crisbeto avatar Feb 19 '17 21:02 crisbeto

Tested in both Chrome 56, Safari 10.0.3. I have also cleared node_modules and reinstalled and continue to see the same issue

benb7760 avatar Feb 19 '17 21:02 benb7760

I couldn't reproduce it with neither of those browsers. Are you sure there isn't anything else in your app that could be messing with it?

crisbeto avatar Feb 19 '17 21:02 crisbeto

I can't see anything that could be doing it. I've stripped my app back completely so that the core view is just this repro, and removed all CSS, still happening

benb7760 avatar Feb 19 '17 21:02 benb7760

I have the same issue Chrome 56, Windows 10. After playing with it for a while the problem seems to be related to position: absolute from .mat-input-placeholder. I can see the label in the plunker above though, so it's a bit weird. However, the labels were fine in beta1. Can you see any problem with this code?

<form (ngSubmit)="logIn()" novalidate #loginForm="ngForm"> <md-input-container> <input mdInput type="text" md-input placeholder="Username" [(ngModel)]="username" name="username" required> </md-input-container> </form>

lukaskopenec avatar Feb 20 '17 11:02 lukaskopenec

We did some changes to the .mat-input-placeholder in beta.2 in order to prevent it from overflowing in IE 11. Still, my best guess is that there's something else influencing it, because I can't reproduce it in a Plunkr or against our development app.

crisbeto avatar Feb 20 '17 12:02 crisbeto

Actually, I think I found what may be causing it. Can @lukaskopenec and @benb7760 check that your index.html has a doctype?

crisbeto avatar Feb 20 '17 12:02 crisbeto

@crisbeto That was it! I had a doctype but with a typo. Thanks for your help!

lukaskopenec avatar Feb 20 '17 12:02 lukaskopenec

@crisbeto Yep that has solved it here too. My DOCTYPE had some extra stuff in it which I have since removed. For reference, it looked like this;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

and I have changed it to

<!DOCTYPE html>

benb7760 avatar Feb 20 '17 16:02 benb7760

I have the same issue. In my case, i forgot to add <!DOCTYPE html> in front of the html tag, after i add the correct doctype, problem solved.

naiteluo avatar Feb 21 '17 10:02 naiteluo

Okay, it looks like this issue was solved by fixing the DOCTYPE? Will close then.

kara avatar Feb 21 '17 20:02 kara

can i just make the notation here that quickstart... lol, which I started my projects from must have not had it in there. just sayin!!!

xtianus79 avatar Feb 23 '17 14:02 xtianus79

I had these symptoms, but it was unrelated to the DOCTYPE. Simply the use of a prebuilt dark theme, purple-green or pink-bluegrey will do and not putting the form inside a container i.e. a md-card

See http://plnkr.co/edit/fElo3SpEtDA5Fy4oLoHb?p=preview for an example

image

Enclosing the form within a container or adding the class 'mat-app-background' to the <body> resolved it.

Stexxen avatar Mar 06 '17 10:03 Stexxen

had the same problem, I didnt even have a doctype on my index page!! problem solved when i added it

Gallopaway avatar Apr 24 '17 04:04 Gallopaway

The same problem on Firefox 53.0.2

placeholder is shown when property of css class is disabled

.mat-input-placeholder-wrapper - overflow: hidden

As written in previous post by @Gallopaway - works properly after adding doctype

prograamer avatar May 12 '17 05:05 prograamer

Like @Stexxen, I also experience these symtoms unrelated to the doctype. Without a wrapper like md-card, the input field doesn't have the required behaviour with all themes: (purple-green vs indigo-pink) screen shot 2017-06-16 at 11 53 27 screen shot 2017-06-16 at 12 06 32

blievrouw avatar Jun 16 '17 10:06 blievrouw

Its happening with me too. Quite irritated by this bug or tweak , whatever it may be! If someone conquered in removing this bug ,please help.

mayankjoshi24 avatar Sep 01 '17 12:09 mayankjoshi24