Add event handlers to RB.DialogView
Review Request #10967 — Created March 27, 2020 and submitted — Latest diff uploaded
This patch adds event handlers to
RB.DialogView
forsubmit
and
keydown
. The formsubmit
event handler fixes the bug where pressing
Enter
on the upload file dialog (RB.UploadAttachmentView
) would
cancel the file upload instead of actually uploading it. Pressing the
return key onRB.DialogView
dialogs that have a completed form will
now submit the form instead of reloading the page and discarding
changes unless theform
specifies an action explicitly. Thekeydown
event handler allows the dialog to be closed when theEscape
key
is pressed.Since
RB.DialogView
is a child of themodalBox
, it needs to listen
tokeydown
events from the main box area and not from its own content
area so that it can handle events from within it. This means we can't
use theevents
map for thekeydown
event and have to bind an explicit
keydown
event handler on.modalbox-inner
.
New unit tests:
- triggeringsubmit
with primary button enabled triggers the button
- triggeringsubmit
with primary button disabled on a dialog does
nothing
- triggeringsubmit
with primary button enabled on a dialog with a
form does nothing
- triggeringkeydown
using theEscape
key hides the dialogManual testing:
File upload dialog:
- pressingEnter
after opening the dialog and not filling out any
fields does nothing
- pressingEnter
after uploading a file & editing the caption uploads
the file with the caption
- pressingEscape
after opening the dialog hides the dialogNew review request dialog:
- pressingEscape
after opening the dialog hides the dialog