Skip to content

Commit

Permalink
fix(app-headless-cms): ensure validation is visible with DelayedOnChange
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed May 23, 2024
1 parent 4970a5a commit 42f3b1c
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,22 @@ const plugin: CmsModelFieldRendererPlugin = {

return (
<Bind>
<DelayedOnChange>
<Input
rows={5}
label={field.label}
placeholder={field.placeholderText}
description={field.helpText}
data-testid={`fr.input.longtext.${field.label}`}
/>
</DelayedOnChange>
{bind => (
<DelayedOnChange
value={bind.value}
onChange={bind.onChange}
onBlur={bind.validate}
>
<Input
rows={5}
label={field.label}
placeholder={field.placeholderText}
description={field.helpText}
data-testid={`fr.input.longtext.${field.label}`}
validation={bind.validation}
/>
</DelayedOnChange>
)}
</Bind>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ const plugin: CmsModelFieldRendererPlugin = {
return (
<DynamicSection {...props}>
{({ bind, index }) => (
<DelayedOnChange {...bind.index}>
<DelayedOnChange
value={bind.index.value}
onChange={bind.index.onChange}
onBlur={bind.index.validate}
>
<Input
validation={bind.index.validation}
rows={5}
label={t`Value {number}`({ number: index + 1 })}
placeholder={props.field.placeholderText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,22 @@ const plugin: CmsModelFieldRendererPlugin = {

return (
<Bind>
<DelayedOnChange>
<Input
label={field.label}
placeholder={field.placeholderText}
description={field.helpText}
type="number"
data-testid={`fr.input.number.${field.label}`}
/>
</DelayedOnChange>
{bind => (
<DelayedOnChange
value={bind.value}
onChange={bind.onChange}
onBlur={bind.validate}
>
<Input
label={field.label}
placeholder={field.placeholderText}
description={field.helpText}
type="number"
data-testid={`fr.input.number.${field.label}`}
validation={bind.validation}
/>
</DelayedOnChange>
)}
</Bind>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ const plugin: CmsModelFieldRendererPlugin = {
return (
<DynamicSection {...props}>
{({ bind, index }) => (
<DelayedOnChange {...bind.index}>
<DelayedOnChange
value={bind.index.value}
onChange={bind.index.onChange}
onBlur={bind.index.validate}
>
<Input
validation={bind.index.validation}
onEnter={() => bind.field.appendValue("")}
label={t`Value {number}`({ number: index + 1 })}
placeholder={props.field.placeholderText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,21 @@ const plugin: CmsModelFieldRendererPlugin = {

return (
<Bind>
<DelayedOnChange>
<Input
label={field.label}
placeholder={field.placeholderText}
description={field.helpText}
data-testid={`fr.input.text.${field.label}`}
/>
</DelayedOnChange>
{bind => (
<DelayedOnChange
value={bind.value}
onChange={bind.onChange}
onBlur={bind.validate}
>
<Input
label={field.label}
placeholder={field.placeholderText}
description={field.helpText}
data-testid={`fr.input.text.${field.label}`}
validation={bind.validation}
/>
</DelayedOnChange>
)}
</Bind>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ const plugin: CmsModelFieldRendererPlugin = {
return (
<DynamicSection {...props}>
{({ bind, index }) => (
<DelayedOnChange {...bind.index}>
<DelayedOnChange
value={bind.index.value}
onChange={bind.index.onChange}
onBlur={bind.index.validate}
>
<Input
validation={bind.index.validation}
onEnter={() => bind.field.appendValue("")}
label={t`Value {number}`({ number: index + 1 })}
placeholder={props.field.placeholderText}
Expand Down

0 comments on commit 42f3b1c

Please sign in to comment.