Merge lp:~rockstar/phazr/fix-clickoutside into lp:phazr

Proposed by Paul Hummer
Status: Merged
Approved by: Paul Hummer
Approved revision: 16
Merged at revision: 12
Proposed branch: lp:~rockstar/phazr/fix-clickoutside
Merge into: lp:phazr
Diff against target: 57 lines (+24/-4)
1 file modified
src/js/phazroverlay/phazroverlay.js (+24/-4)
To merge this branch: bzr merge lp:~rockstar/phazr/fix-clickoutside
Reviewer Review Type Date Requested Status
Martin Albisetti (community) Approve
Phazr team Pending
Review via email: mp+66646@code.launchpad.net

Commit message

Fix a bug in the "click outside" of the modal overlay.

Description of the change

This branch fixes an odd race condition where the click event that shows overlay gets bubbled up to html, handled by the "click outside" handler, and essentially hides the overlay before it ever actually gets shown.

THIS WAS A TERRIBLE THING TO TRY AND TRACK DOWN. I lost about a day's worth of hard work, and probably a piece of my soul trying to get it figured out.

To post a comment you must log in.
lp:~rockstar/phazr/fix-clickoutside updated
15. By Paul Hummer

Abstract out the attach and detach

16. By Paul Hummer

Fixed that one issue (because I am a genius)

Revision history for this message
Martin Albisetti (beuno) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/js/phazroverlay/phazroverlay.js'
2--- src/js/phazroverlay/phazroverlay.js 2011-06-07 15:29:33 +0000
3+++ src/js/phazroverlay/phazroverlay.js 2011-07-01 19:39:29 +0000
4@@ -23,6 +23,8 @@
5 closeContainer.one('.' + className + '-close-button'));
6 },
7 afterBindUI: function() {
8+ this.after('renderedChange', this.afterRenderedChange, this);
9+ this.after('visibleChange', this.afterVisibleChange, this);
10 this.get('closeButton').on('click', this.hide, this);
11 Y.on('keyup', function(e) {
12 if (e.keyCode == 27) {
13@@ -31,23 +33,41 @@
14 }, window, this);
15
16 var box = this.get('boundingBox'),
17+ className = this.getClassName(),
18 header = box.one('.' + className + '-hd'),
19- className = this.getClassName(),
20 dd = new Y.DD.Drag({
21 node: box,
22 handle: header
23 });
24 this.set('dragDelegate', dd);
25-
26- Y.one("html").on("modaloutside|click",
27+ },
28+ afterRenderedChange: function(e) {
29+ if (e.newVal === false) { return; }
30+ if (this.get('visible') === true) {
31+ this.attachModalOutside();
32+ }
33+ },
34+ afterVisibleChange: function(e) {
35+ if (e.newVal === true) {
36+ this.attachModalOutside();
37+ } else {
38+ this.detachModalOutside();
39+ }
40+ },
41+ attachModalOutside: function() {
42+ var box = this.get('boundingBox');
43+ Y.one("html").on("modaloutside|click",
44 function(e) {
45 var targ = e.target;
46 if (!box.contains(targ)) {
47 this.hide();
48 Y.detach("modaloutside|click");
49 }
50- },
51+ },
52 this);
53+ },
54+ detachModalOutside: function() {
55+ Y.one("html").detach("modaloutside|click");
56 }
57 };
58

Subscribers

People subscribed via source and target branches

to all changes: