It would be kind of neat to be able to close the modal on panels via the escape button.

It might or might not make sense to add a setting for this

Comments

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new1001 bytes

Here is a patch.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed, pushed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

tomogden’s picture

Category: feature » bug
Status: Closed (fixed) » Needs review
StatusFileSize
new996 bytes

BUG ALERT!

@merlinofchaos,

This patch doesn't work for Chrome or Safari because 'keypress' cannot capture the escape key. Binding the 'keypress' event also seems to conflict with the modalEventHandler binding above it.

I have attached a revised patch where the ONLY change is the 'keypress' event is replaced by the 'keydown' event in 3 places. This works in Chrome and Safari, as well as old and new versions of FireFox and eliminates any possible conflicts with modalEventHandler. I can't verify IE here, but maybe someone else can verify it for me.

dave reid’s picture

Component: Code » Modal
tim.plunkett’s picture

The current code binds to $(document) but unbinds $('body'). I couldn't get this to work in chrome/safari, with keypress, keyup, or keydown.

However, dreditor does something similar, and it *does* work: http://drupalcode.org/project/dreditor.git/blob/refs/heads/master:/dredi...

nagiek’s picture

Not meaning to hijack the thread, but could we also add a setting to dismiss the modal by clicking on the background?

nagiek’s picture

Similar patch as #327139: Close lightbox when background overlay is clicked, but for using #modalBackdrop should do it.

merlinofchaos’s picture

I would want that to be an optional behavior; ESC can be standard, that's relatively normal and okay, but the background click, that strikes me as being way too easy to do by accident and causing lost work.

tim.plunkett’s picture

Status: Needs review » Needs work

Marking CNW per #6 and #9.

vgoodvin’s picture

StatusFileSize
new1.83 KB

I created patch to closing modal window by clicking on backdrop. I tested it in Chromium 18 and in Firefox 11. Escape button also didn't work for me in Chromium. So it also fixed.

vgoodvin’s picture

Status: Needs work » Needs review
tomogden’s picture

Status: Needs review » Reviewed & tested by the community

This tests correctly for me on Chrome, Firefox and Safari on PC and Mac and IE8 on PC. Tested correctly also on Chromium 18 for Mac.

pixelmord’s picture

Tested patch from #11 against CTOOLS 7.x-1.2.

Works fine for me in Safari and Chrome on Mac, other browsers I did not test up to now.

Thanks for the patch!

howto’s picture

The patch from #11 works perfectly on Chrome, Firefox but it don't work on Chromium.

mrsinguyen’s picture

Tested with patch #11, work fine for me.

socialnicheguru’s picture

it works for me too

dawehner’s picture

+++ b/js/modal.jsundefined
@@ -425,7 +426,17 @@
+        close();
+        return false;

I'm not 100% familiar with the perfect way to write javascript but isn't using event.preventDefault();
the way to go?

merlinofchaos’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

You know, I don't think clicking on the backdrop should close the modal. There's way too much possibility of data loss just for clicking on the background. Sorry, but I will not be committing this.

SebCorbin’s picture

Status: Closed (won't fix) » Active

Err, wasn't the subject about "escape key", not "backdrop click" ?

SebCorbin’s picture

Status: Active » Closed (fixed)

Sorry I was using version 7.x-1.2, this has been fixed by commit 0ec61b4

El Alemaño’s picture

Issue summary: View changes
StatusFileSize
new1.61 KB
El Alemaño’s picture

El Alemaño’s picture

StatusFileSize
new1.52 KB
El Alemaño’s picture

StatusFileSize
new1.52 KB