Skip to content

Commit

Permalink
don't set validation classes on inputs that don't provide an errors r…
Browse files Browse the repository at this point in the history
…ecord

When a set of input rows provide an errors record, it is used to set if
a field is valid or invalid. When this property is not provided, the
CSS classes that indicate valid or invalid fields must not be added to
the input elements.
  • Loading branch information
Alex Ashley authored and asrashley committed Feb 7, 2025
1 parent 0136135 commit 2577f0c
Show file tree
Hide file tree
Showing 10 changed files with 483 additions and 625 deletions.
192 changes: 96 additions & 96 deletions frontend/src/__snapshots__/App.test.tsx.snap

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/src/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function Input({
const disabled = useComputed<boolean>(() => !!disabledFields[name]);
const inputClass = useComputed<string>(() => {
const formCls = type === "checkbox" ? "form-check-input" : type === "select" ? "form-select" : "form-control";
const err = error.value ? " is-invalid" : " is-valid";
const err = error ? (error.value ? " is-invalid" : " is-valid") : "";
return `${formCls}${err} ${className}`;
});

Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/InputFieldRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export function InputFieldRow({
? cgiName
: `${prefix}${prefix ? "__" : ""}${fullName}`;
const describedBy = text ? `text-${name}`: `label-${name}`;
const error = useComputed(() => errors?.value[name]);
const errorSig = useComputed(() => errors?.value[name]);
const error = errors ? errorSig : undefined;

return (
<FormRow name={name} label={title} text={text} layout={layout} error={error} {...props}>
<Input
Expand Down
Loading

0 comments on commit 2577f0c

Please sign in to comment.