Skip to content
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

Dialogs with a Form inside are closed on outside click #3214

Open
HDinger opened this issue Dec 2, 2024 · 0 comments
Open

Dialogs with a Form inside are closed on outside click #3214

HDinger opened this issue Dec 2, 2024 · 0 comments
Assignees
Labels

Comments

@HDinger
Copy link
Contributor

HDinger commented Dec 2, 2024

Steps to reproduce

<%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: title, subtitle: subtitle)) do |d| %>
  <% d.with_show_button { button_text } %>
  <form class="pt-3">
    <%= render(Primer::Alpha::Dialog::Body.new) do %>
      This is a custom dialog with the body and footer wrapped in a form tag.
      <input id="dialog-text-input-example" type="text" value="Some text goes in here" autocomplete="off">
    <% end %>
    <%= render(Primer::Alpha::Dialog::Footer.new(show_divider: show_divider)) do %>
      <%= render(Primer::Beta::Button.new(data: { "close-dialog-id": "my-dialog" })) { "Cancel" } %>
      <%= render(Primer::Beta::Button.new(scheme: :primary, type: :submit)) { "Submit" } %>
    <% end %>
  </form>
<% end %>

Actual behavior

  • An outside click closes the dialog and all unsaved changes are gone

Expected behavior

  • In the docs it says:

By default, clicking on the backdrop will dismiss the dialog. However, if the dialog contains a form that can have unsaved changes, the backdrop won't dismiss the dialog, regardless of the state of the form.

@sunnyi101 sunnyi101 self-assigned this Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants