components: MatFormField placeholders problematic on production builds
Bug, feature request, or proposal:
Bug
What is the expected behavior?
When the user inputs text to MatInput or selects an option in MatSelect, the placeholder should disappear (as defined by the MAT_LABEL_GLOBAL_OPTIONS) and form validations should activate.
What is the current behavior?
The behavior works as expected on development builds. However when bundled with “ng build -prod” we get the following outcomes:
- MatInput: text starts typing behind the placeholder text. only when you click on the input field does the placeholder disappear.
- MatSelect: the select box either refuses to open, or when opened clicking on an option does nothing.
These behaviors also affect form validations.
What are the steps to reproduce?
build an app with the -prod flag
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
when tested on a demo app with the following package.json configuration, we get expected behavior
"dependencies": { "@angular/animations": "^4.0.0", "@angular/cdk": "^2.0.0-beta.8", "@angular/common": "^4.0.0", "@angular/compiler": "^4.0.0", "@angular/core": "^4.0.0", "@angular/forms": "^4.0.0", "@angular/http": "^4.0.0", "@angular/material": "^2.0.0-beta.8", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/router": "^4.0.0", "core-js": "^2.4.1", "hammerjs": "^2.0.8", "material-design-icons": "^3.0.1", "rxjs": "^5.4.1", "zone.js": "^0.8.14" }, "devDependencies": { "@angular/cli": "1.3.1", "@angular/compiler-cli": "^4.0.0", "@angular/language-service": "^4.0.0", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~8.0.17", "codelyzer": "~3.1.2", "firebase-tools": "^3.9.1", "jasmine-core": "~2.7.0", "jasmine-spec-reporter": "~4.2.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.2.0", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "ts-node": "~3.3.0", "tslint": "~5.6.0", "typescript": "~2.4.2" }
however when updated to Angular v.5 packages, the demo app also fails to produce expected behavior.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 26 (13 by maintainers)
@oytuneyucel, @kd2801:
As suggested by @filipesilva (the problem seems to be related to
uglify-es@3.3.2
):So, temporarily:
1 - add
uglify-es@3.2.2
to dependencies array in package.json 2 - delete package-lock.json, node_modules and dist 3 - npm installOr, to linux users:
We just released
@angular/cli@1.6.3
which works around a problem in uglify that causes this. See angular/angular-cli#8997 for more information.Now I tried to do what is stated in the comments again. It worked. Apparently the cache was not cleared at the first attempts.
Very bad bug! It took a long time to find the problem… 😦
@julianobrasil I can confirm that @filipesilva 's solution does work for our project and uglify-es 3.3.0 indeed causes the problem with the production build