unbridled-41 opened a new issue, #4587:
URL: https://github.com/apache/rocketmq-dashboard/issues/4587
## Problem
On `/settings` (通用设置 tab) the page loads the settings record once and fills
the notification and security forms from that snapshot. That load effect lists
the translation function `t` as a dependency, and `t` is recreated whenever the
display language changes (`web/src/i18n/LangContext.tsx`). Switching the
language through the top-bar toggle therefore re-runs the effect and
repopulates both forms from the server — silently discarding everything the
operator had typed but not yet saved.
Steps to reproduce:
1. Open `/settings`, 通用设置 tab.
2. Edit the DingTalk webhook (or 邮件接收人 / 会话超时) without saving.
3. Switch the display language with the top-bar toggle.
4. The field reverts to the server value; no message is shown and the edit
is lost.
## Studio Version
branch: master
git commit id: d50ffecc9d7e8f8f46da64198831bd7952e6974e
deployed as: built from source (frontend only)
## Evidence
- `web/src/pages/settings/GeneralSettingsTab.tsx:100` — the effect's
dependency list is `[message, notifyForm, securityForm, t]`, while the effect
body calls `securityForm.setFieldsValue(...)` and
`notifyForm.setFieldsValue(...)` (`:81-:88`). `Form.useForm()` and
`App.useApp().message` are stable, so `t` is the only dependency that forces a
re-run.
- Regression test
`web/src/pages/settings/__tests__/GeneralSettingsFormResidue.test.tsx` switches
the language through the real `LangProvider.setLang` and fails on `master`:
```
FAIL src/pages/settings/__tests__/GeneralSettingsFormResidue.test.tsx >
GeneralSettingsTab unsaved input > keeps unsaved notification edits when the
display language changes
Error: expect(element).toHaveValue(...)
Expected the element to have value:
https://oapi.dingtalk.com/robot/send?access_token=edited
Received:
https://oapi.dingtalk.com/robot/send?access_token=server
❯ src/pages/settings/__tests__/GeneralSettingsFormResidue.test.tsx:108:21
Test Files 1 failed (1)
Tests 1 failed (1)
```
## Impact
An operator who switches the display language while configuring notification
channels loses the values they were about to save — for example a DingTalk
signing secret or a new recipient list — with no warning and no way to recover
them from the page.
## Expected behavior
Changing the display language re-renders text only. Editor content that the
user has typed but not saved must survive it, as it does in the sibling tabs
that load once per mount.
## Related work
- In-repo precedent for decoupling the load effect from the translation
function: `web/src/pages/studio/LiteTopic.tsx:126-161` and the follow-up in
#2200 (merged) keep a `translationRef`/`messageRef` pair and load with
mount-only deps.
- #4284 (merged) — the same settings record must not lose fields a user has
not edited; this issue is the client-side twin (input a user has not saved).
## PR
Fix: #PR_PLACEHOLDER.
--
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]