Skip to content

Commit 494991e

Browse files
fix(textarea): float label when a value is changed async (#18024)
emits styles to the parent item on value change so that the item will get the proper class to float the label fixes #17555 fixes #17559
1 parent 1199c53 commit 494991e

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

core/src/components/textarea/test/basic/e2e.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ test('textarea: basic', async () => {
55
url: '/src/components/textarea/test/basic?ionic:_testing=true'
66
});
77

8-
const compare = await page.compareScreenshot();
9-
expect(compare).toMatchScreenshot();
8+
const compares = [];
9+
10+
compares.push(await page.compareScreenshot());
11+
12+
page.waitFor(2000);
13+
compares.push(await page.compareScreenshot('value changed'));
14+
15+
for (const compare of compares) {
16+
expect(compare).toMatchScreenshot();
17+
}
1018
});

core/src/components/textarea/test/basic/index.html

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</ion-item>
3030

3131
<ion-item>
32-
<ion-label color="primary" fixed>Fixed Label</ion-label>
32+
<ion-label color="primary" position="fixed">Fixed Label</ion-label>
3333
<ion-textarea placeholder="Textarea"></ion-textarea>
3434
</ion-item>
3535

@@ -38,13 +38,13 @@
3838
</ion-item>
3939

4040
<ion-item>
41-
<ion-label color="primary" stacked>Stacked Label</ion-label>
41+
<ion-label color="primary" position="stacked">Stacked Label</ion-label>
4242
<ion-textarea placeholder="Textarea"></ion-textarea>
4343
</ion-item>
4444

4545
<ion-item>
46-
<ion-label color="primary" floating>Floating Label</ion-label>
47-
<ion-textarea></ion-textarea>
46+
<ion-label color="primary" position="floating">Floating Label</ion-label>
47+
<ion-textarea id="timeout"></ion-textarea>
4848
</ion-item>
4949

5050
<ion-item>
@@ -58,24 +58,14 @@
5858
</ion-item>
5959

6060
<ion-item>
61-
<ion-label>Dynamic Value</ion-label>
62-
<ion-input id="dynamicValue" value="dynamic"></ion-input>
63-
</ion-item>
64-
65-
<ion-item>
66-
<ion-label>Dynamic Value</ion-label>
67-
<ion-textarea id="dynamicTextareaValue" value="dynamic"></ion-textarea>
61+
<ion-label position="floating">Dynamic Value</ion-label>
62+
<ion-textarea id="dynamicValue" value="dynamic"></ion-textarea>
6863
</ion-item>
6964

7065
<ion-item>
7166
<ion-label color="primary">Clear on Edit</ion-label>
7267
<ion-textarea clear-on-edit="true"></ion-textarea>
7368
</ion-item>
74-
75-
<ion-item>
76-
<ion-label color="primary">Clear on Edit</ion-label>
77-
<ion-input clear-on-edit="true"></ion-input>
78-
</ion-item>
7969
</ion-list>
8070

8171
<div text-center>
@@ -87,17 +77,22 @@
8777
Toggle Readonly
8878
</ion-button>
8979

90-
<ion-button color="light" onclick="toggleString('dynamicValue', 'value'); toggleString('dynamicTextareaValue', 'value')">
80+
<ion-button color="light" onclick="toggleString('dynamicValue', 'value');">
9181
Toggle Value
9282
</ion-button>
9383

94-
<ion-button color="danger" onclick="clearString('dynamicValue', 'value'); clearString('dynamicTextareaValue', 'value')">
84+
<ion-button color="danger" onclick="clearString('dynamicValue', 'value');">
9585
Clear Value
9686
</ion-button>
9787
</div>
9888
</ion-content>
9989

10090
<script>
91+
var textarea = document.getElementById('timeout');
92+
setTimeout(() => {
93+
textarea.value = 'timeout';
94+
}, 1000);
95+
10196
function toggleBoolean(id, prop) {
10297
var el = document.getElementById(id);
10398

core/src/components/textarea/textarea.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export class Textarea implements ComponentInterface {
134134
if (nativeInput && nativeInput.value !== value) {
135135
nativeInput.value = value;
136136
}
137+
this.emitStyle();
137138
this.ionChange.emit({ value });
138139
}
139140

0 commit comments

Comments
 (0)