File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @primer/view-components ' : patch
3+ ---
4+
5+ Do not close dialogs when clicking on the backdrop if the dialog contains a form
Original file line number Diff line number Diff line change @@ -111,6 +111,9 @@ export class DialogHelperElement extends HTMLElement {
111111 // The click target _must_ be the dialog element itself, and not elements underneath or inside.
112112 if ( target !== dialog || ! dialog ?. open ) return
113113
114+ // If the dialog contains a form, do not close the dialog when clicking outside of the dialog
115+ if ( dialog . querySelector ( 'form' ) ) return
116+
114117 const rect = dialog . getBoundingClientRect ( )
115118 const clickWasInsideDialog =
116119 rect . top <= event . clientY &&
Original file line number Diff line number Diff line change @@ -89,6 +89,15 @@ def test_outside_click_closes_dialog
8989 refute_selector "dialog[open]"
9090 end
9191
92+ def test_outside_click_does_not_close_dialog_with_form
93+ visit_preview ( :with_form )
94+
95+ click_button ( "Show Dialog" )
96+ mouse . click ( x : 0 , y : 0 )
97+
98+ assert_selector "dialog[open]"
99+ end
100+
92101 def test_outside_menu_click_does_not_close_dialog
93102 visit_preview ( :with_auto_complete )
94103
You can’t perform that action at this time.
0 commit comments