yyqdbngt opened a new pull request, #2872:
URL: https://github.com/apache/rocketmq-dashboard/pull/2872
## Summary
- Replace the fragile inline AutoComplete `filterOption` in the studio
Producer page (`pages/studio/Producer.tsx`) with an exported
`matchesProducerGroupOption` helper.
- The old expression was
`option?.value.toLowerCase().includes(inputValue.toLowerCase()) ?? false`. The
`?? false` only protects the case where `option` itself is nullish (the
optional chain short-circuits); it does NOT protect the cases that actually
throw:
- `option.value` is `null`/`undefined` (e.g. a `null` group in the API
response) → `TypeError: Cannot read properties of null (reading 'toLowerCase')`
inside the dropdown render;
- a non-string `option.value` (number, etc.) → same `TypeError`.
- The new helper coerces both sides with `String(...) ?? ''` so any option
value or search string is compared safely, case-insensitively.
## Why
The producer-group selector builds its options from live API data
(`fetchProducerGroups`), unlike the static topic/instance selectors. A single
malformed payload entry therefore used to throw inside antd's filter path and
break the whole suggestion dropdown. The same defensive `String(option?.label
?? '')` pattern is already used in `components/InstanceSelect.tsx`; this brings
the Producer selector in line with it.
## Testing
- `cd web && ./node_modules/.bin/vitest run
src/pages/studio/__tests__/producerGroupFilter.test.ts` — 5 new regression
tests passed (case-insensitive match, empty input, null/undefined/non-string
option values, undefined input).
- `cd web && ./node_modules/.bin/vitest run
src/pages/studio/__tests__/Producer.test.tsx` — 13 pre-existing tests still
pass.
- `cd web && ./node_modules/.bin/tsc --noEmit` — clean.
- `cd web && ./node_modules/.bin/eslint src/pages/studio/Producer.tsx
src/pages/studio/__tests__/producerGroupFilter.test.ts` — 0 errors (1
react-refresh warning for the exported helper, same precedent as other
page-level helper exports).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]