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

v2.0.0-beta.5 Toast not dismissing after timeout #137

Closed
J-T-McC opened this issue Oct 23, 2020 · 5 comments
Closed

v2.0.0-beta.5 Toast not dismissing after timeout #137

J-T-McC opened this issue Oct 23, 2020 · 5 comments
Labels
Priority: High Issues that break most user's experience Status: In Progress Currently assigned and being worked on Type: Bug Something isn't working

Comments

@J-T-McC
Copy link

J-T-McC commented Oct 23, 2020

Versions

v2.0.0-beta.5

Describe the bug

Toast is not dismissed after the timeout expires even though the timeoutHandler test is passing. Changing the event listeners to camel case in VtToast.vue makes the dismiss work but the timeoutHandler test no longer passes while "emits close-toast on animationend" does. Changing the event to single word (i.e. 'dismiss') throughout and all tests + timeout dismiss works

Expected behavior

Toast dismissed after timeout expires

Steps to reproduce

add v2.0.0-beta.5 package

Reproduction: demo.

Steps:

  1. Install v2.0.0-beta.5
  2. Set up plugin
  3. Toggle toast

Your Environment

VueJS 3.0.1

Latest Chrome

@J-T-McC J-T-McC added Status: Available Type: Bug Something isn't working labels Oct 23, 2020
@restyler
Copy link

I can confirm the bug on vue@3.0.2 + vue-toastification@2.0.0-beta.5

@emresudo
Copy link

I can confirm the bug on vue@3.0.0 + vue-toastification@2.0.0-beta.5

@Maronato
Copy link
Owner

Hello!
Thank you for reporting this and for your analysis.

I've done some digging and found that the issue seems to come from this commit on vue-next. What it does is change how the event listener name is normalized.

Here is an example from the Template Explorer showing how, before the change, the following template

<div @close-toast="doStuff">Hello World!</div>

Would get compiled to:

export function render(_ctx, _cache, $props, $setup, $data, $options) {
  return (_openBlock(), _createBlock("div", { "onClose-toast": _ctx.doStuff }, "Hello World!", 40 /* PROPS, HYDRATE_EVENTS */, ["onClose-toast"]))
}

In fact, Vue-Toastification's v2.0.0-beta.5 distribution code looks like:

typeof _ctx.content === 'string')
        ? (openBlock(), createBlock(Fragment, { key: 0 }, [
            createTextVNode(toDisplayString(_ctx.content), 1 /* TEXT */)
          ], 64 /* STABLE_FRAGMENT */))
        : (openBlock(), createBlock(resolveDynamicComponent(_ctx.getVueComponentFromObj(_ctx.content)), mergeProps({
            key: 1,
            "toast-id": _ctx.id
          }, _ctx.content.props, toHandlers(_ctx.content.listeners), { "onClose-toast": _ctx.closeToast }), null, 16 /* FULL_PROPS */, ["toast-id", "onClose-toast"]))
    ], 10 /* CLASS, PROPS */, ["role"]),

After the change, however, a handler for close-toast gets compiled to onCloseToast, as you can see it in this other example from the Template Explorer.

The same template as above now gets compiled to:

export function render(_ctx, _cache, $props, $setup, $data, $options) {
  return (_openBlock(), _createBlock("div", { onCloseToast: _ctx.doStuff }, "Hello World!", 40 /* PROPS, HYDRATE_EVENTS */, ["onCloseToast"]))
}

The fix, then, should be as simple as recompiling the library using the newest version of compiler-dom. My local tests show that once recompiled, the issues are gone.

I'll create a PR and push these changes into the next release, so please give it a try.

@Maronato Maronato added Priority: High Issues that break most user's experience Status: In Progress Currently assigned and being worked on and removed Status: Available labels Oct 24, 2020
@Maronato Maronato mentioned this issue Oct 24, 2020
9 tasks
@Maronato
Copy link
Owner

@J-T-McC The issue seems to be fixed now. Please try it out :)

Edit vue3 (forked)

@J-T-McC
Copy link
Author

J-T-McC commented Oct 25, 2020

Thanks @Maronato, all good now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High Issues that break most user's experience Status: In Progress Currently assigned and being worked on Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants