Skip to content

fix(web): trim whitespace in cluster overview search normalization - #2871

Open
yyqdbngt wants to merge 1 commit into
apache:rocketmq-studiofrom
yyqdbngt:codex/yy-cluster-search
Open

fix(web): trim whitespace in cluster overview search normalization#2871
yyqdbngt wants to merge 1 commit into
apache:rocketmq-studiofrom
yyqdbngt:codex/yy-cluster-search

Conversation

@yyqdbngt

Copy link
Copy Markdown

Summary

  • Make the cluster overview page's shared searchText normalizer trim user input in addition to being null-safe and lower-casing it (pages/cluster/index.tsx).
  • Export searchText for unit coverage and add regression tests:
    • new unit suite pages/cluster/clusterSearchText.test.ts (trim / empty / whitespace-only / null / undefined input);
    • new page-level test in ClusterPage.test.tsx: submitting a whitespace-only broker search keeps all broker rows visible.

Why

The broker / NameServer / Proxy panels all use Input.Search with onSearch, so a submission of only spaces previously produced a non-empty normalized keyword. Since "".includes(" ") is false for every row, a whitespace-only search silently hid the entire table until the user cleared the box. The certs and clients pages already trim their search input; the overview page was the remaining outlier in the cluster domain.

Testing

  • cd web && ./node_modules/.bin/vitest run src/pages/cluster/clusterSearchText.test.ts src/pages/cluster/__tests__/ClusterPage.test.tsx — 2 files, 24 tests passed (3 new unit tests, 1 new page-level regression test; all pre-existing tests still pass).
  • cd web && ./node_modules/.bin/tsc --noEmit — clean.
  • cd web && ./node_modules/.bin/eslint src/pages/cluster/index.tsx src/pages/cluster/clusterSearchText.test.ts src/pages/cluster/__tests__/ClusterPage.test.tsx — 0 errors (1 react-refresh warning for the exported helper, same precedent as other page-level helper exports).

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Good catch — whitespace-only search silently hid all rows because "".includes(" ") is false. The fix aligns the cluster overview with the certs/clients pages that already trim. Tests cover the regression well.

LGTM.


Automated review by github-manager-bot

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Defensive fix that improves input validation and error handling. Code looks clean and follows existing patterns.

LGTM


Automated review by "github-manager-bot"

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — defensive fix improving input validation and error handling.


Automated review by "github-manager-bot"

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.

3 participants