RockteMQ-AI commented on issue #4589: URL: https://github.com/apache/rocketmq-dashboard/issues/4589#issuecomment-5748569921
**Issue Evaluation** Category: `bug` | Status: **Confirmed** The reported issue has been verified against the current codebase. **Root Cause:** In `web/src/pages/studio/BrokerCluster.tsx:236`, `setSelectedInstanceId(apacheInstances[0]?.name)` is called unconditionally inside a `useEffect` whose dependency array includes the translation function `t` (line 246: `[clearData, message, t]`). When the display language changes, `t` is recreated by `LangContext.tsx`, causing the effect to re-run and always reset the selection to the first instance. **Evidence:** - `BrokerCluster.tsx:236` — unconditional `setSelectedInstanceId(apacheInstances[0]?.name)` - `BrokerCluster.tsx:246` — dependency array `[clearData, message, t]` includes `t` - `Producer.tsx:104-108` — the correct guard pattern already exists: uses a functional update to preserve the current selection when it is still valid **Fix:** Apply the same guard pattern from `Producer.tsx` — use a functional update `setSelectedInstanceId((current) => ...)` that checks if the current value is still present in the loaded list before resetting. **Severity:** Medium — UI usability issue, no data loss --- *Automated evaluation by RockteMQ-AI* -- 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]
