Topic: Text style menu interrupts editing in a routed page
webcraft_io
free
asked 4 weeks ago
Our router reacts when a user chooses a paragraph style in the editor. The edit screen resets before the content is saved.
Can these controls render as buttons?
Mateusz Lazaru
staff
answered 4 weeks ago
First check whether choosing a style changes the location or submits the surrounding form. Either action can remount a routed edit screen and clear unsaved local state. Log the editor's mount/unmount cycle and repeat the test with the editor outside the form.
For a toolbar you control, use action buttons with type="button" and keep the existing formatting handler. Please send the toolbar JSX or generated HTML, router configuration, and a small reproduction demonstrating the reset. That will help us determine whether the navigation comes from the toolbar or an application handler.
https://mdbootstrap.com/docs/react/plugins/wysiwyg-editor/
webcraft_io free commented 4 weeks ago
Found it in our custom toolbar: the style button had no type and was submitting the surrounding form. Adding type="button" stopped the route reset while keeping the formatting handler working. The draft stays in place now. Thanks for pointing us toward the form submission.
<button type="button" onClick={() => applyStyle('h2')}>
Heading
</button>
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: MDB React
- MDB Version: MDB5 9.0.0
- Device: Desktop
- Browser: Chrome
- OS: macOS
- Provided sample code: No
- Provided link: No