Skip to content

Commit

Permalink
fix(race conditions with lazyRender and showDelay)
Browse files Browse the repository at this point in the history
  • Loading branch information
kybishop committed May 24, 2018
1 parent c6cc99f commit 22d3963
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions addon/components/attach-popover.js
Expand Up @@ -377,6 +377,8 @@ export default Component.extend({
_showAfterDelay() {
cancel(this._delayedVisibilityToggle);

this.set('_shouldRender', true);

this._addListenersForHideEvents();

const showDelay = parseInt(this.get('showDelay'));
Expand All @@ -391,8 +393,6 @@ export default Component.extend({
return;
}

this.set('_shouldRender', true);

// Make the attachment visible immediately so transition animations can take place
this._setIsVisibleAfterDelay(true, 0);

Expand Down Expand Up @@ -460,6 +460,7 @@ export default Component.extend({
this._removeListenersForHideEvents();

this._animationTimeout = requestAnimationFrame(() => {
// Avoid a race condition where we attempt to hide after the component is being destroyed.
if (this.isDestroyed || this.isDestroying) {
return;
}
Expand Down Expand Up @@ -489,8 +490,8 @@ export default Component.extend({
const hideOn = this.get('_hideOn');
const target = this._currentTarget;

// Target was destroyed
if (!target) {
// Target or component was destroyed
if (!target || this.isDestroyed || this.isDestroying) {
return;
}

Expand Down Expand Up @@ -561,7 +562,7 @@ export default Component.extend({
// If cursor is not on the attachment or target, hide the popper
if (!target.contains(event.target)
&& !(this.get('isOffset') && this._isCursorBetweenTargetAndAttachment(event))
&& !this._popperElement.contains(event.target)) {
&& (this._popperElement && !this._popperElement.contains(event.target))) {
// Remove this listener before hiding the attachment
delete this._hideListenersOnDocumentByEvent.mousemove;
document.removeEventListener('mousemove', this._hideIfMouseOutsideTargetOrAttachment);
Expand Down

0 comments on commit 22d3963

Please sign in to comment.