HubSpot / messenger

Growl-style alerts and messages for your app. #hubspot-open-source
http://github.hubspot.com/messenger/
MIT License
4.03k stars 408 forks source link

Instance location does not update correctly #99

Open jeffjenk opened 8 years ago

jeffjenk commented 8 years ago

We are using messenger to deploy messages to multiple locations within our app. For example we deploy messages to the page header by default but to a modal window if a modal is currently deployed on the page.

When a message first deploys the instance location is set. If the location changes there is a comparison between the instance location and the chosen location and the message is moved to the chosen location but the instance location is not updated to reflect the new chosen location. This causes messages to stop displaying if the location changes back to the instance location like if modal window is closed for example.

We propose the following update to fix this bug:

// Current code
...
} else if (!$(inst._location).is($(chosen_loc))) {
  inst.$el.detach();
  $parent.prepend(inst.$el);
}
...
// Proposed fix
...
} else if (!$(inst._location).is($(chosen_loc))) {
  inst.$el.detach();
  $parent.prepend(inst.$el);
  inst._location = chosen_loc;
}
...