@motor-hero/ui-kit 0.37.2 → 0.37.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -64,13 +64,21 @@ export interface FormDialogProps extends Omit<BaseDialogProps, "contentWrapper">
|
|
|
64
64
|
* plain BaseDialog.
|
|
65
65
|
*/
|
|
66
66
|
export function FormDialog({ onSubmit, ...rest }: FormDialogProps) {
|
|
67
|
+
// O conteúdo do dialog é portalado para o body, mas eventos React sobem pela
|
|
68
|
+
// árvore React, não pela do DOM: sem stopPropagation, o submit deste form
|
|
69
|
+
// chega ao <form> da página que renderiza o dialog e dispara o submit dela.
|
|
70
|
+
// Precisa ser síncrono — handlers de RHF são assíncronos (resolver).
|
|
71
|
+
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
|
72
|
+
e.stopPropagation()
|
|
73
|
+
onSubmit?.(e)
|
|
74
|
+
}
|
|
67
75
|
return (
|
|
68
76
|
<BaseDialog
|
|
69
77
|
{...rest}
|
|
70
78
|
contentWrapper={
|
|
71
79
|
onSubmit
|
|
72
80
|
? (content) => (
|
|
73
|
-
<form onSubmit={
|
|
81
|
+
<form onSubmit={handleSubmit} className="flex min-h-0 flex-1 flex-col">
|
|
74
82
|
{content}
|
|
75
83
|
</form>
|
|
76
84
|
)
|