kaxil commented on code in PR #63900:
URL: https://github.com/apache/airflow/pull/63900#discussion_r2956657084


##########
airflow-core/src/airflow/ui/src/pages/Pools/PoolForm.tsx:
##########
@@ -87,23 +87,32 @@ const PoolForm = ({ error, initialPool, isPending, 
manageMutate, setError }: Poo
       <Controller
         control={control}
         name="slots"
-        render={({ field }) => (
-          <Field.Root mt={4}>
+        render={({ field, fieldState }) => (
+          <Field.Root invalid={Boolean(fieldState.error)} mt={4}>
             <Field.Label 
fontSize="md">{translate("pools.form.slots")}</Field.Label>
             <Input
               min={-1}
+              onBlur={field.onBlur}
               onChange={(event) => {
-                const value = event.target.valueAsNumber;
+                const { value: raw, valueAsNumber } = event.target;
 
-                field.onChange(isNaN(value) ? field.value : value);
+                field.onChange(raw === "" ? Number.NaN : valueAsNumber);
               }}
+              ref={field.ref}
               size="sm"
               type="number"
-              value={field.value}
+              value={Number.isFinite(field.value) ? field.value : ""}
             />
-            
<Field.HelperText>{translate("pools.form.slotsHelperText")}</Field.HelperText>
+            {fieldState.error ? (
+              <Field.ErrorText>{fieldState.error.message}</Field.ErrorText>
+            ) : (
+              
<Field.HelperText>{translate("pools.form.slotsHelperText")}</Field.HelperText>
+            )}
           </Field.Root>
         )}
+        rules={{
+          validate: (value) => Number.isFinite(value) || 
translate("common:validation.mustBeValidNumber"),
+        }}

Review Comment:
   Since you're adding validation rules here, worth also adding `min: { value: 
-1, message: translate("...") }` to match the server-side `ge=-1` constraint. 
Right now a user can type `-100`, pass client validation, and only get a server 
error back. Not a regression from this PR, just a nice addition while the 
validation plumbing is already in place.



-- 
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]

Reply via email to