unbridled-41 opened a new pull request, #4890:
URL: https://github.com/apache/rocketmq-dashboard/pull/4890

   ## Problem
   
   On the Producer page, switching the display language silently throws away 
the operator's query scope: the selected TOPIC and PRODUCER GROUP are cleared, 
so the page cannot run a query until both are picked again.
   
   ## Evidence
   
   `web/src/pages/studio/Producer.tsx` (base `1ef5d860`):
   
   ```ts
   const fetchTopicFailedMessage = t('producer.fetchTopicFailed');   // :90 — a 
value of the current language
   ...
   useEffect(() => {
       ...
       form.setFieldsValue({ selectedTopic: undefined, producerGroup: undefined 
});   // :153
       void fetchTopicList(selectedInstanceId)...
   }, [fetchTopicFailedMessage, form, message, selectedInstanceId]);            
       // :171
   ```
   
   `t` is rebuilt by `LangProvider` on every language change, so 
`fetchTopicFailedMessage` changes identity and the effect re-runs — even though 
nothing about the instance changed. The reset was written for the instance 
transition (the topic list belongs to the instance, and `handleInstanceChange` 
clears the same fields), but it runs on every effect run.
   
   Reproduction (deterministic Vitest, 
`web/src/pages/studio/__tests__/Producer.test.tsx` › `keeps the picked topic 
and producer group when the display language changes`): pick `order-events`, 
type `order-producer`, click the language switch. On the unfixed source the 
topic selection is gone — `Unable to find an element with the text: 
order-events, which matches selector '.ant-select-selection-item'` — and the 
group input is empty, so the follow-up query cannot carry the scope the 
operator chose.
   
   This is the same defect class the project has already fixed twice: #4590 
(merged, `BrokerCluster` instance selection) and #4818 (open, `Ops` NameServer 
selection).
   
   ## Root cause
   
   A localized string participated in the effect's dependencies, so a language 
switch re-ran an effect whose destructive step belongs to the instance 
transition only.
   
   ## Fix
   
   The reset is now keyed to the instance: `lastResetInstanceRef` records the 
instance the form was cleared for, and the reset only runs when 
`selectedInstanceId` actually changes. The instance transition (initial 
auto-selection and a manual switch) behaves exactly as before, while the extra 
effect run caused by a language change leaves the selection alone. The topic 
list is still refetched, so the localized failure message keeps following the 
language.
   
   ## Tests
   
   - `npx vitest run src/pages/studio/__tests__/Producer.test.tsx` → **16 
passed** (15 pre-existing + the new regression).
   - The new test fails on the unfixed source with the selector error quoted 
above.
   - `npx vitest run src/pages/studio` → **85 passed** (8 files), so the 
instance-change reset (`clears the previous instance's scope`, `queries after 
switching instances`) is unchanged.
   - `npx tsc --noEmit` → clean; `npx eslint src/pages/studio/Producer.tsx 
src/pages/studio/__tests__/Producer.test.tsx` → clean.
   
   ## Scoring
   
   PRIORITY 56 (impact 16: the page is left unable to query until the scope is 
re-entered, and the loss is silent; reach 12: the language switch is a top-bar 
control on every page; reproducibility 16: deterministic test; maintenance 
value 12: closes the third instance of a class the project already treats as a 
bug). FIX_CONFIDENCE 88.
   
   ## Risk
   
   Low. Only the *timing* of the reset changes, and only for a re-run that does 
not come from an instance change; the instance path is covered by the 
pre-existing tests. No behaviour change for the query, the export, or the 
localized error message.
   


-- 
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]

Reply via email to