-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modal as Form returns error, and Modal no longer centers on screen #1012
Comments
This is because the However, when rendering This is actually the same problem we have in #659. We need a way to reliably get the DOM node of both DOM components (e.g. a We can at least isolate the job finding DOM nodes to a transparent wrapping element. I made a very rough example here: http://www.react.run/HJa1BVYQl/19 that shows we can find the DOM node for any functional/class DOM/composite component. Will have to sleep on this, but likely we'll need to add some utility for this. |
Thanks for the detailed explanation, @levithomason. Very helpful. Thanks again! |
I've managed to put a form into modal this way:
|
Thanks for the hack, @bakatrouble. But won't work in our case. |
@CaryLandholt we still want to fix this, though, does the |
Our need is to use a In order to support submitting via Enter key, the submit @bakatrouble's approach has the submit button outside of the We also tried the reverse - to surround the <Form onSubmit={submit}>
<Modal>
<Modal.Content>...</Modal.Content>
<Modal.Actions>
<Button type="submit">Submit</Button>
</Modal.Actions>
</Modal>
</Form> |
As of HTML5, you do not need to have the button inside the form. You can do this with the |
Right, this is what @bakatrouble suggested. However, we are constructing the actions separate from the content and wanted to avoid needing to pass the form name down. We also have other forms on the same page so the form names would need to be unique. |
I see. The other option here is to hoist your form state and use a callback to submit the data. |
Yeah - was hoping to avoid workarounds and hacks to just use a form within a modal |
Closing for housekeeping. |
Steps
<Modal as={Form}... />
Expected Result
Vertically centered Modal without exceptions
Actual Result
Uncaught TypeError: _this._modalNode.getBoundingClientRect is not a function
and Modal is positioned below the center line
Can do
<Form as={Modal}.../>
but lose the ability to press the Enter key to submit the formVersion
0.62.0
The text was updated successfully, but these errors were encountered: