Copilot commented on code in PR #3295:
URL: https://github.com/apache/apisix-dashboard/pull/3295#discussion_r2954492677
##########
src/routes/services/detail.$id/index.tsx:
##########
@@ -61,6 +61,7 @@ const ServiceDetailForm = (props: Props) => {
shouldFocusError: true,
mode: 'all',
disabled: readOnly,
+ defaultValues: serviceData?.value,
});
Review Comment:
In `react-hook-form`, `defaultValues` are only applied on the initial
`useForm` call; if `serviceData` is undefined on first render (common with
non-suspense queries), this won’t actually seed defaults for later
re-registrations, so it may not fully address the “reset to component
defaultValue” issue described in the PR. A more reliable approach is to ensure
defaults are set when data arrives (e.g., always `reset` with fetched values
and let RHF update its internal defaults, or use RHF’s `values` option to
reinitialize from fetched data), so re-registered fields consistently derive
from fetched state rather than component-level defaults.
##########
src/routes/stream_routes/detail.$id.tsx:
##########
@@ -15,9 +15,9 @@
* limitations under the License.
*/
import { zodResolver } from '@hookform/resolvers/zod';
-import { Button, Group,Skeleton } from '@mantine/core';
+import { Button, Group } from '@mantine/core';
import { notifications } from '@mantine/notifications';
-import { useMutation, useQuery } from '@tanstack/react-query';
+import { useMutation, useSuspenseQuery } from '@tanstack/react-query';
Review Comment:
Similar to the Route detail page, this removes the component’s `isLoading`
Skeleton path and depends on Suspense for the loading state. Confirm that a
Suspense fallback exists for this route so loading remains user-friendly and
doesn’t regress to a blank render.
--
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]