Skip to content

Commit

Permalink
fix(textarea): we need to set the value length state initially as well (
Browse files Browse the repository at this point in the history
#2692)

* fix: we need to set this state initially as well

* fix: "referenceError: h is not defined"

* refactor: resilience
  • Loading branch information
mfranzke authored Jul 31, 2024
1 parent ab8799e commit 7a0e87f
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { Component, Host, h, Prop, State, Event } from '@stencil/core';
import { uuid } from '../../utils/utils';

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

private textareaElement!: HTMLTextAreaElement;

/**
* 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.
*/
Expand Down Expand Up @@ -127,6 +130,10 @@ export class DbTextarea {
*/
@Event() dbChange;

componentDidRender() {
this.valueSize = this.textareaElement?.value?.length || 0;
}

render() {
return (
<Host>
Expand Down Expand Up @@ -156,6 +163,7 @@ export class DbTextarea {
rows={this.rows}
wrap={this.wrap}
data-variant={this.variant}
ref={(el) => (this.textareaElement = el as HTMLTextAreaElement)}
onInput={(event) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down

0 comments on commit 7a0e87f

Please sign in to comment.