RockteMQ-AI commented on PR #4564:
URL:
https://github.com/apache/rocketmq-dashboard/pull/4564#issuecomment-5747087352
## 🔍 PR Review by RockteMQ-AI
**PR #4564**: fix(message): keep the history drawer search visible after
reopening
**Files**: 2 changed (+97 -0)
---
## Summary
The fix correctly keeps the search input in sync with the persisted applied
filter by introducing a controlled `searchDraft` and restoring it from `search`
whenever the drawer reopens. I verified the targeted suite passes (6/6) and
`tsc`/`eslint` are clean.
## Issues found
- `web/src/components/MessageQueryHistoryDrawer.tsx:106-115` uses a
render-phase `setState` to detect the `open` transition. It works, but it is
less idiomatic than an effect and can trigger an extra synchronous render on
every open/close. Consider replacing it with a `useEffect(() => { if (open)
setSearchDraft(search); }, [open, search]);` to avoid render-phase state
updates.
- `web/src/components/__tests__/MessageQueryHistoryDrawer.test.tsx` covers
the reopen and clear cases well, but does not assert that reopening actually
reuses the previous `search` parameter in the API call (it only checks the
input value). Adding that assertion would tighten the regression coverage.
## Suggestions for improvement
1. Move the open-sync logic into `useEffect` for clarity and to avoid
render-phase setState.
2. Add an assertion in the reopen test that `listMessageQueryHistory` is
called again with `search: 'order-1'` after reopening.
3. Consider adding a test for the no-prior-search reopen case to ensure no
spurious API change.
## Overall assessment
APPROVE
The change is small, state-only, and fixes the reported UX bug without
touching any API contracts. Tests pass locally and the code is type/lint clean.
The render-phase state update works but is worth simplifying in a follow-up.
---
<sub>🤖 Automated review by RockteMQ-AI | Review dimensions: correctness,
performance, tests, compatibility</sub>
--
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]