messere1 opened a new pull request, #6372: URL: https://github.com/apache/rocketmq-dashboard/pull/6372
## What The add/edit data source dialog (`web/src/pages/settings/DataSourceTab.tsx`) guards its OK button with the `submitting` state, but that flag only flips **after** `dsForm.validateFields()` resolves and React re-renders. A second confirmation click inside that window runs `handleSubmit` again, so the same `createDataSource` (or `updateDataSource`) write goes on the wire twice — and a double-created data source then shows up as two rows in the inventory. This is a different race from #5216, which handles a save completing after the operator cancelled and reopened the modal; here the trigger is simply two clicks on the same still-enabled OK button. ## How - Guard `handleSubmit` with a synchronous `submittingRef` flipped before any `await`, so the second click in the validate window is a no-op. - Move `setSubmitting(true)` ahead of `validateFields` so `confirmLoading` reflects the lock immediately (the button now shows its spinner from the first click, not only after validation passes). ## Verification Red/green with `web/src/pages/settings/__tests__/DataSourceTab.test.tsx` (vitest + testing-library): - New test `creates each data source once per modal confirmation` fills the create dialog, clicks OK twice inside the validate window, and asserts `createDataSource` is called exactly once with the typed values. Without the source change the OK button never gains `ant-btn-loading` before the second click and the test fails; with it, it passes. - The test was run against the patch (pass) and against the unpatched source (fail); the rest of the suite stays green. -- 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]
