Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling goAway() on global toast causes "Cannot read property 'includes' of undefined" and toast does not clear #38

Closed
esmsnt opened this issue Oct 3, 2017 · 1 comment

Comments

@esmsnt
Copy link

esmsnt commented Oct 3, 2017

It looks like the instance.cached_options object is empty on global toasts.

For the moment I just modified the if in _goAway to check if position is defined and avoid the error:
if (instance.cached_options.position && instance.cached_options.position.includes('bottom')) {

This is the definition of the global toast done in main.js right after setting up Toasted.

Vue.use(Toasted, {
  position: 'top-right',
  duration: 5000,
  theme: 'primary'
})
Vue.toasted.register('cookieNotification',
  (thisVue) => {
    // Use thisVue instance to resolve some routes in here
    var toastContent = 'some notification content'
    return toastContent
  },
  {type: 'info',
    position: 'bottom-right',
    duration: null,
    className: 'cookie-alert',
    onComplete: function () {
      var d = new Date()
      d.setTime(d.getTime() + (14 * 24 * 60 * 60 * 1000))
      var expires = 'expires=' + d.toUTCString()
      document.cookie = 'cookieNotice=true;' + expires + ';path=/'
    },
    action: {
      text: 'X',
      onClick: (e, toastObject) => {
        var d = new Date()
        d.setTime(d.getTime() + (14 * 24 * 60 * 60 * 1000))
        var expires = 'expires=' + d.toUTCString()
        document.cookie = 'cookieNotice=true;' + expires + ';path=/'
        toastObject.goAway(0)  //This is where the issue occurs
      }
    }
  }
)
@shakee93
Copy link
Owner

shakee93 commented Oct 3, 2017

Thanks. will be fixed in the coming version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants