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.DialogViewforsubmitand
keydown. The formsubmitevent handler fixes the bug where pressing
Enteron the upload file dialog (RB.UploadAttachmentView) would
cancel the file upload instead of actually uploading it. Pressing the
return key onRB.DialogViewdialogs that have a completed form will
now submit the form instead of reloading the page and discarding
changes unless theformspecifies an action explicitly. Thekeydown
event handler allows the dialog to be closed when theEscapekey
is pressed.Since
RB.DialogViewis a child of themodalBox, it needs to listen
tokeydownevents 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 theeventsmap for thekeydownevent and have to bind an explicit
keydownevent handler on.modalbox-inner.
New unit tests:
- triggeringsubmitwith primary button enabled triggers the button
- triggeringsubmitwith primary button disabled on a dialog does
nothing
- triggeringsubmitwith primary button enabled on a dialog with a
form does nothing
- triggeringkeydownusing theEscapekey hides the dialogManual testing:
File upload dialog:
- pressingEnterafter opening the dialog and not filling out any
fields does nothing
- pressingEnterafter uploading a file & editing the caption uploads
the file with the caption
- pressingEscapeafter opening the dialog hides the dialogNew review request dialog:
- pressingEscapeafter opening the dialog hides the dialog