Skip to content

Commit 7a0e87f

Browse files
authoredJul 31, 2024··
fix(textarea): we need to set the value length state initially as well (#2692)
* fix: we need to set this state initially as well * fix: "referenceError: h is not defined" * refactor: resilience
1 parent ab8799e commit 7a0e87f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎packages/db-ui-elements-stencil/src/components/db-textarea/db-textarea.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
12
import { Component, Host, h, Prop, State, Event } from '@stencil/core';
23
import { uuid } from '../../utils/utils';
34

@@ -9,6 +10,8 @@ import { uuid } from '../../utils/utils';
910
export class DbTextarea {
1011
@State() valueSize = 0;
1112

13+
private textareaElement!: HTMLTextAreaElement;
14+
1215
/**
1316
* The ariainvalid attribute is used to indicate that the value entered into an input field does not conform to the format expected by the application.
1417
*/
@@ -127,6 +130,10 @@ export class DbTextarea {
127130
*/
128131
@Event() dbChange;
129132

133+
componentDidRender() {
134+
this.valueSize = this.textareaElement?.value?.length || 0;
135+
}
136+
130137
render() {
131138
return (
132139
<Host>
@@ -156,6 +163,7 @@ export class DbTextarea {
156163
rows={this.rows}
157164
wrap={this.wrap}
158165
data-variant={this.variant}
166+
ref={(el) => (this.textareaElement = el as HTMLTextAreaElement)}
159167
onInput={(event) => {
160168
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
161169
// @ts-ignore

0 commit comments

Comments
 (0)
Please sign in to comment.