@@ -28,6 +28,7 @@ type Props = {
28
28
autoFocus ?: boolean ;
29
29
disableFocusLock ?: boolean ;
30
30
className ?: string ;
31
+ disabled ?: boolean ;
31
32
onClose : ( ) => void ;
32
33
onSubmit ?: ( ) => void | Promise < void > ;
33
34
} ;
@@ -42,6 +43,7 @@ export const Modal: FC<Props> = ({
42
43
autoFocus = false ,
43
44
disableFocusLock = false ,
44
45
className,
46
+ disabled = false ,
45
47
onClose,
46
48
onSubmit,
47
49
} ) => {
@@ -103,7 +105,7 @@ export const Modal: FC<Props> = ({
103
105
aria-labelledby = "modal-header"
104
106
tabIndex = { - 1 }
105
107
>
106
- < MaybeWithForm onSubmit = { onSubmit } >
108
+ < MaybeWithForm onSubmit = { onSubmit } disabled = { disabled } >
107
109
{ closeable && < ModalCloseIcon onClose = { ( ) => closeModal ( "x" ) } /> }
108
110
{ title ? (
109
111
< >
@@ -127,8 +129,9 @@ export default Modal;
127
129
128
130
type MaybeWithFormProps = {
129
131
onSubmit : Props [ "onSubmit" ] ;
132
+ disabled : Props [ "disabled" ] ;
130
133
} ;
131
- const MaybeWithForm : FC < MaybeWithFormProps > = ( { onSubmit, children } ) => {
134
+ const MaybeWithForm : FC < MaybeWithFormProps > = ( { onSubmit, disabled , children } ) => {
132
135
const handleSubmit = useCallback (
133
136
( e : FormEvent ) => {
134
137
e . preventDefault ( ) ;
@@ -147,7 +150,7 @@ const MaybeWithForm: FC<MaybeWithFormProps> = ({ onSubmit, children }) => {
147
150
return (
148
151
< form onSubmit = { handleSubmit } >
149
152
{ /* including a hidden submit button ensures submit on enter works despite a button w/ type="submit" existing or not */ }
150
- < input type = "submit" className = "hidden" hidden />
153
+ < input type = "submit" className = "hidden" hidden disabled = { disabled } />
151
154
{ children }
152
155
</ form >
153
156
) ;
0 commit comments