Skip to content

Conversation

@DavidLi236888
Copy link
Contributor

@DavidLi236888 DavidLi236888 commented Jul 21, 2024

Description
This pull request addresses a bug where the "Insert Image" button and certain toolbar actions (Insert Horizontal Rule and Insert Break Line) would unintentionally trigger the submission of section_dialog

Fixed Problem

  • Issue: The "Insert Image" button would unintentionally cause the section_dialog to submit, closing the form. (issue [Bug] Can't insert image in a category other than summary #1996)
  • Issue: The "Insert Horizontal Rule" and "Insert Break Line" buttons in the editor toolbar would trigger the submission of section_dialog, make these buttons unusable.

Changes Made

  1. Prevent Default Form Submission for Insert Image
    Updated the InsertImageForm component to use e.stopPropagation() and e.preventDefault() in the onSubmit handler. This prevents the image insertion from causing the parent form to submit.

  2. Set type="button" for Toolbar Buttons:
    Ensured the "Insert Horizontal Rule" and "Insert Break Line" buttons in the toolbar have type="button" to prevent them from submitting the parent form.

Testing

  • Clicking the "Insert Image" button inserts the image without submitting the section_dialog form.
  • Using the "Insert Horizontal Rule" and "Insert Break Line" buttons performs the respective actions without submitting the section_dialog form

Related Issues
Fixes #1996

This is my first contribution to an open-source project. Please let me know if there are any issues or areas for improvement. Thank you!

@DavidLi236888 DavidLi236888 changed the title Fix: Prevent Unintentional Form Submission on Image Insert and Toolbar Actions Fix(client): Prevent Unintentional Form Submission on Image Insert and Toolbar Actions Jul 21, 2024
@DavidLi236888 DavidLi236888 changed the title Fix(client): Prevent Unintentional Form Submission on Image Insert and Toolbar Actions Fix(client): Fix Unintentional Form Submission on Image Insert and Toolbar Actions Jul 21, 2024
@DavidLi236888 DavidLi236888 changed the title Fix(client): Fix Unintentional Form Submission on Image Insert and Toolbar Actions Fix(client): Fix Unintentional Form Submission on Rich-input Toolbar Actions Jul 21, 2024
@AmruthPillai
Copy link
Owner

Thank you for the PR!

@AmruthPillai AmruthPillai merged commit d0a0768 into AmruthPillai:main Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Can't insert image in a category other than summary

3 participants