Topic: Choosing a row action submits the surrounding filter form
julesWeb21
asked a week ago
Our results table sits below filter controls inside one form. Choosing a row action opens the expected drawer but also sends the filter form, which immediately replaces the table and closes the drawer.
The action is a custom button rendered inside a dropdown item. I can see both our action handler and the form submit handler in the console after a single click. The button does not currently declare a type.
Mateusz Lazaru
staff answered a week ago
Set type="button" on the row action button. A button associated with a form otherwise defaults to a submit action, so your click handler can run successfully and still be followed by the form submission.
Keep type="submit" only on the actual filter submit control. Check the rendered button element if a wrapper component is involved; the type must reach that native element rather than remaining on a surrounding dropdown item.
<button type="button" onClick={() => openDetails(row.id)}>
View details
</button>
https://mdbootstrap.com/docs/react/components/dropdowns/
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: MDB React
- MDB Version: MDB5 9.0.0
- Device: Laptop
- Browser: Firefox
- OS: Windows 11
- Provided sample code: No
- Provided link: No