Skip to content

feat(ui): display live character counter in MetadataStep description textarea #1212

Description

@Emmyt24

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

  1. Run pnpm test --filter frontend to ensure no regressions.
  2. 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>.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions