Closed rianne-pagtalunan closed 5 years ago
Hi @rianne-pagtalunan, facing the same problem. Got any solution?
hi @akki-jat, still nothing. I've switched to using fixed/stacked labels when text-area has a value as a temporary workaround.
@rianne-pagtalunan I am using a hack. Just disable then set value and enable the textarea JS/TS code.
Same problem
Thanks for the issue! I believe this is related to Angular forms. Could you test to see if it works setting the value with ngModel
?
We did this
<ion-list>
<ion-item>
<ion-label position="floating">Test 1</ion-label>
<ion-textarea clearInput></ion-textarea>
</ion-item>
<ion-item>
<ion-label position="floating">Test 2</ion-label>
<ion-textarea clearInput value="YES"></ion-textarea>
</ion-item>
<ion-item>
<ion-label position="floating">Test 3</ion-label>
<ion-textarea clearInput [value]="angular"></ion-textarea>
</ion-item>
<ion-item>
<ion-label position="floating">Test 4</ion-label>
<ion-textarea clearInput [value]="angularAsync"></ion-textarea>
</ion-item>
<ion-item>
<ion-label position="floating">Test 5</ion-label>
<ion-textarea clearInput [(ngModel)]="angularNgModel"></ion-textarea>
</ion-item>
<ion-item>
<ion-label position="floating">Test 6</ion-label>
<ion-textarea clearInput [(ngModel)]="angularAsyncNgModel"></ion-textarea>
</ion-item>
</ion-list>
And this is the result:
As you can see if using angular or ngmodel binding which is async the floating label is not working. All the other use cases are working
Thanks so much @mburger81! That helps a lot. I confirmed that this happens to textarea with a setTimeout on it in core, without Angular. It does not happen to the ion-input
. Here's a Codepen reproducing it: https://codepen.io/brandyscarney/pen/XQgwJM
I'll add it to the project. I think the problem is as simple as this.emitStyle()
not being called on value change:
@Watch('value')
protected valueChanged() {
const nativeInput = this.nativeInput;
const value = this.getValue();
if (nativeInput && nativeInput.value !== value) {
nativeInput.value = value;
}
this.ionChange.emit({ value });
}
I'll take a quick look at this.
That was definitely the problem, submitted a pull request with the fix: https://github.com/ionic-team/ionic/pull/18024
Try with value=" ". It should be working.
version 4.3.0 definitely resolves the issue for us
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Bug Report
Ionic version: [x] 4.x
Current behavior: When a default value is present for an ion-textarea, the ion-label does not float properly. Ion-item css styles shows the css class
item-input
instead ofitem-has-value
. This behavior is observed using latestbeta.16
of ionic/angularThe behavior corrects when focus has been applied to the ion-textarea.
Expected behavior: When an ion-textarea has a value, the label should float properly.
Steps to reproduce:
Related code:
Other information:
Ionic info: