Skip to content

Commit

Permalink
refactor(input-field): make it easier to understand when to render he…
Browse files Browse the repository at this point in the history
…lper line
  • Loading branch information
Kiarokh committed Nov 6, 2023
1 parent 8af7ff6 commit ea1afd1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/components/input-field/input-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,19 @@ export class InputField {
this.isModified = true;
};

private hasHelperText = () => {
return this.helperText !== null && this.helperText !== undefined;
};

private hasHelperLine = () => {
return this.maxlength || this.hasHelperText();
};

private renderHelperLine = () => {
const text: string = this.value || '';
const length = text.length;

if (!this.maxlength && !this.hasHelperText()) {
if (!this.hasHelperLine()) {
return;
}

Expand All @@ -499,10 +507,6 @@ export class InputField {
}
};

private hasHelperText = () => {
return this.helperText !== null && this.helperText !== undefined;
};

private renderSuffix = () => {
if (!this.hasSuffix() || this.type === 'textarea') {
return;
Expand Down

0 comments on commit ea1afd1

Please sign in to comment.