Image Pipeline Playground
refactor: Simplify select field handling and remove unused Controller import in NodeInspector
Mohammad Rajaeic5590d745bfb
diff --git a/frontend/src/features/inspector/NodeInspector.tsx b/frontend/src/features/inspector/NodeInspector.tsxindex 608daae..d255b9e 100644--- a/frontend/src/features/inspector/NodeInspector.tsx+++ b/frontend/src/features/inspector/NodeInspector.tsx@@ -1,5 +1,5 @@import { useEffect } from 'react'-import { Controller, useForm } from 'react-hook-form'+import { useForm } from 'react-hook-form'import { z } from 'zod'import { zodResolver } from '@hookform/resolvers/zod'import {@@ -47,7 +47,7 @@ export function NodeInspector() {const isLoadImage = selected?.data.type === 'load_image'const isAnnotations = selected?.data.type === 'annotations'- const { register, handleSubmit, reset, control, setValue, formState } = useForm({+ const { register, handleSubmit, reset, setValue, formState } = useForm({resolver: zodResolver(schema),defaultValues: selected?.data.params ?? {},})@@ -213,38 +213,31 @@ export function NodeInspector() {return null}if (field.type === 'select' && field.options) {- const options = field.optionsreturn (- <Controller+ <TextFieldkey={`${selected.id}:${field.name}`}- name={field.name}- control={control}- render={({ field: inputField }) => (- <TextField- select- size="small"- label={field.label}- helperText={field.description ?? undefined}- value={String(selected.data.params[field.name] ?? '')}- onChange={(event) => {- const value = event.target.value- inputField.onChange(value)- setValue(field.name, value, {- shouldDirty: true,- shouldValidate: true,- })- updateNodeParams(selected.id, { [field.name]: value })- }}- onBlur={inputField.onBlur}- >- {options.map((option) => (- <MenuItem key={option} value={option}>- {option}- </MenuItem>- ))}- </TextField>+ select+ size="small"+ label={field.label}+ helperText={field.description ?? undefined}+ value={String(+ selected.data.params[field.name] ?? field.default ?? '',)}- />+ onChange={(event) => {+ const value = event.target.value+ setValue(field.name, value, {+ shouldDirty: true,+ shouldValidate: true,+ })+ updateNodeParams(selected.id, { [field.name]: value })+ }}+ >+ {field.options.map((option) => (+ <MenuItem key={option} value={option}>+ {option}+ </MenuItem>+ ))}+ </TextField>)}