Description
The MetadataStep component in frontend/src/components/TokenDeployForm/MetadataStep.tsx already computes remainingChars = MAX_DESCRIPTION_LENGTH - description.length (line ~29) and enforces a 500-character cap, but never renders this counter in the UI. Users have no way to know how many characters they have left until the field silently stops accepting input. This issue adds a live counter below the textarea.
Requirements and Context
- Security: Input length is already enforced server-side; the counter is display-only and introduces no new attack surface.
- Testing: Update or add a test in
frontend/src/components/TokenDeployForm/__tests__/ that simulates typing into the description field and asserts the counter text updates correctly, including the "near limit" warning color change.
- Documentation: No external docs required; the
MAX_DESCRIPTION_LENGTH constant is self-documenting.
Suggested Execution
git checkout -b feat/metadata-step-char-counter
Implement Changes
- Below the
<textarea> (or <Input>) for the description field in MetadataStep.tsx, render a <span> or <p> showing {remainingChars} characters remaining.
- Apply a warning style (e.g.,
text-red-500) when remainingChars <= 50 so users know they are approaching the limit.
- When
remainingChars === 0 show "Character limit reached" and disable the field's ability to accept more input (the maxLength HTML attribute is the simplest mechanism).
- Keep the counter hidden when the metadata toggle is off (
includeMetadata === false) since the textarea is also hidden in that state.
Test and Commit
- Run
pnpm test --filter frontend to ensure no regressions.
- Manually test both the green state (>50 chars remaining) and the red warning state (<= 50) in the dev server.
Example Commit Message
feat(ui): add live character counter to MetadataStep description field
Co-authored-by: <your-name> <your-email>
Guidelines
- Do not introduce a third-party character-count library — plain arithmetic on
description.length is sufficient.
- Keep the PR scoped to
MetadataStep.tsx and its test file only.
- Open the PR against
main and link it to this issue with Closes #<issue-number>.
Description
The
MetadataStepcomponent infrontend/src/components/TokenDeployForm/MetadataStep.tsxalready computesremainingChars = MAX_DESCRIPTION_LENGTH - description.length(line ~29) and enforces a 500-character cap, but never renders this counter in the UI. Users have no way to know how many characters they have left until the field silently stops accepting input. This issue adds a live counter below the textarea.Requirements and Context
frontend/src/components/TokenDeployForm/__tests__/that simulates typing into the description field and asserts the counter text updates correctly, including the "near limit" warning color change.MAX_DESCRIPTION_LENGTHconstant is self-documenting.Suggested Execution
Implement Changes
<textarea>(or<Input>) for the description field inMetadataStep.tsx, render a<span>or<p>showing{remainingChars} characters remaining.text-red-500) whenremainingChars <= 50so users know they are approaching the limit.remainingChars === 0show "Character limit reached" and disable the field's ability to accept more input (themaxLengthHTML attribute is the simplest mechanism).includeMetadata === false) since the textarea is also hidden in that state.Test and Commit
pnpm test --filter frontendto ensure no regressions.Example Commit Message
Guidelines
description.lengthis sufficient.MetadataStep.tsxand its test file only.mainand link it to this issue withCloses #<issue-number>.