dengliming commented on code in PR #687:
URL: https://github.com/apache/shenyu-dashboard/pull/687#discussion_r4114164837
##########
src/routes/Document/components/ApiDebug.js:
##########
@@ -144,7 +144,7 @@ const FCForm = forwardRef(({ form, onSubmit }, ref) => {
}, [apiDetail.httpMethod]);
useEffect(() => {
- setInitialValue({ url: apiDetail.apiPath });
+ setInitialValue((prev) => ({ ...prev, url: apiDetail.apiPath }));
Review Comment:
[P1] Clear the previous mock identity when switching APIs
Spreading `prev` also retains the saved mock ID when the user switches from
API A to API B. `ApiDoc.handleSelectNode` updates `apiDetail` before awaiting
`getApiMockRequest`, so while B's mock request is pending (or if it fails),
this mounted form displays B's path but still holds A's mock ID. Clicking Reset
then calls `deleteMockRequest` with A's ID and deletes A's saved mock. Admin's
`MockRequestRecordServiceImpl.delete` deletes directly by that ID.
I reproduced this with a mounted component test: load A with `mock-a`,
change the context to B while leaving A's mock in place, then click Reset; the
delete call receives `mock-a`. The same regression test passes when this
one-line change is reverted. Preserve the state only while the API identity is
unchanged, and clear or disable mock mutations when the displayed API and
loaded mock do not match. Please add coverage for switching APIs while the mock
request is delayed or fails.
--
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]