@@ -5,6 +5,7 @@ import { autoRelationshipForm } from "../../../AutoInput.js";
5
5
import { RelationshipContext , useAutoRelationship , useRelationshipContext } from "../../../hooks/useAutoRelationship.js" ;
6
6
import { useHasManyController } from "../../../hooks/useHasManyController.js" ;
7
7
import { getRecordAsOption , useOptionLabelForField } from "../../../hooks/useRelatedModel.js" ;
8
+ import { useRequiredChildComponentsValidator } from "../../../hooks/useRequiredChildComponentsValidator.js" ;
8
9
import type { OptionLabel } from "../../../interfaces/AutoRelationshipInputProps.js" ;
9
10
import type { ShadcnElements } from "../../elements.js" ;
10
11
import { makeShadcnRenderOptionLabel } from "../../utils.js" ;
@@ -28,6 +29,7 @@ export const makeShadcnAutoHasManyForm = ({
28
29
secondaryLabel ?: OptionLabel ;
29
30
tertiaryLabel ?: OptionLabel ;
30
31
} ) {
32
+ useRequiredChildComponentsValidator ( props , "AutoHasManyForm" ) ;
31
33
const { metadata } = useAutoRelationship ( { field : props . field } ) ;
32
34
const { getValues } = useFormContext ( ) ;
33
35
@@ -90,7 +92,16 @@ export const makeShadcnAutoHasManyForm = ({
90
92
< Button variant = "destructive" id = { `deleteButton_${ metadataPathPrefix } .${ idx } ` } onClick = { ( ) => remove ( idx ) } >
91
93
Delete
92
94
</ Button >
93
- < Button variant = "default" id = { `confirmButton_${ metadataPathPrefix } .${ idx } ` } onClick = { ( ) => setEditingIndex ( null ) } >
95
+ < Button
96
+ variant = "default"
97
+ type = "button"
98
+ id = { `confirmButton_${ metadataPathPrefix } .${ idx } ` }
99
+ onClick = { ( e ) => {
100
+ e . preventDefault ( ) ;
101
+ e . stopPropagation ( ) ;
102
+ setEditingIndex ( null ) ;
103
+ } }
104
+ >
94
105
Confirm
95
106
</ Button >
96
107
</ div >
@@ -107,7 +118,7 @@ export const makeShadcnAutoHasManyForm = ({
107
118
onClick = { ( ) => setEditingIndex ( idx ) }
108
119
className = ""
109
120
>
110
- < AccordionTrigger >
121
+ < AccordionTrigger onClick = { ( e ) => e . preventDefault ( ) } >
111
122
{ option . label ? (
112
123
< div className = "flex justify-between" >
113
124
< div className = "flex flex-col gap-2" >
0 commit comments