Skip to content

feat(forms): bound SearchPage query length with accessible feedback (#271)#369

Open
jd5073356-max wants to merge 1 commit into
Grainlify:mainfrom
jd5073356-max:forms/searchpage-maxlength
Open

feat(forms): bound SearchPage query length with accessible feedback (#271)#369
jd5073356-max wants to merge 1 commit into
Grainlify:mainfrom
jd5073356-max:forms/searchpage-maxlength

Conversation

@jd5073356-max

Copy link
Copy Markdown

Closes #271

What

The dashboard search input (src/features/dashboard/pages/SearchPage.tsx) had no length bound and no feedback, so a user could paste a massive query that was silently debounced and searched.

Changes

  • maxLength: maxLength={100} on the search input (MAX_SEARCH_LENGTH constant).
  • Accessible counter: an aria-live="polite" counter appears once the query is within 20 characters of the limit, showing {length}/100, and announces Character limit reached at the cap. The input is wired with aria-describedby="search-input-counter".
  • Trim before search: matching now uses debouncedQuery.trim().toLowerCase(), so padded queries match cleanly and whitespace-only queries yield no results. The existing 300ms debounce (useDebouncedValue) is unchanged.

Tests

Extended SearchPage.test.tsx (existing 9 tests still pass) with: maxLength attribute enforced, counter hidden for short queries, counter shown with aria-live when approaching the limit, "limit reached" announced at the cap, trimmed query returns results, whitespace-only treated as empty.

Verification

  • npm run typecheck — passes.
  • SearchPage.test.tsx — 15/15 pass. Coverage of SearchPage.tsx: 100% lines / 100% statements / 100% functions.
  • Genuineness: reverting the component change makes the new tests fail, confirming they assert real behavior.

Security

The length cap reduces the oversized-query payload surface sent to the backend.

…rainlify#271)

The dashboard search input had no length bound or feedback, so very long
pasted queries were silently debounced and sent to search.

- Add maxLength={100} to the search input.
- Show an aria-live character counter as the query approaches the limit,
  with a "Character limit reached" message at the cap.
- Trim leading/trailing whitespace before searching (debounce unchanged).
- Extend SearchPage tests: maxLength attribute, counter near/at the limit,
  trimmed query matching, and whitespace-only handling.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a maxLength bound and accessible counter to the dashboard SearchPage input

1 participant