Skip to content

Commit 4e861f9

Browse files
committed
fix to modals for chrome 60 where the modal gets closed quicker than injection can be sent
1 parent f5efaa5 commit 4e861f9

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

changes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## 2.1.1 - unreleased
44

55
- pat-modal: Only add a panel-header to the first panel-content element within pat-modal, not everyone. Otherwise this may collide with pat-collapsible which also creates a panel-content class further down the DOM (pilz)
6-
6+
- pat-modal: Fix an issue where chrome is so quick that a modal is closed before the actual injection call can be sent.
77

88
## 2.1.0 - Jun. 26, 2017
99

src/pat/modal/modal.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,23 @@ define([
147147
utils.redraw(this.$el.find(".panel-body"));
148148
}
149149
},
150-
151150
destroy: function() {
152-
$(document).off(".pat-modal");
153-
this.$el.remove();
154-
$('body').removeClass("modal-active");
155-
}
151+
var $el = this.$el;
152+
if ($el.find('form').hasClass('pat-inject') ) {
153+
// if pat-inject in modal form, listen to patterns-inject-triggered and destroy first
154+
// once that has been triggered
155+
$('body').on( "patterns-inject-triggered", function() {
156+
$(document).off(".pat-modal");
157+
$el.remove();
158+
$('body').removeClass("modal-active");
159+
});
160+
} else {
161+
// if working without injection, destroy right away.
162+
$(document).off(".pat-modal");
163+
$el.remove();
164+
$('body').removeClass("modal-active");
165+
}
166+
}
156167
});
157168
});
158169

0 commit comments

Comments
 (0)