Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(textarea): we need to set the value length state initially as well #2692

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading