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

onTransitionEnd can be triggered by child elements #43

Closed
rickieshi opened this issue Jan 16, 2019 · 2 comments
Closed

onTransitionEnd can be triggered by child elements #43

rickieshi opened this issue Jan 16, 2019 · 2 comments
Labels

Comments

@rickieshi
Copy link

I found out that transitionend event emitted from child element inside modal component can trigger modal to be prematurely close.
If I added a check in on-transition-end.js like so then it works. I'm not sure if the intention was to catch all transitionend event but it looks like a bug to me.

export default function onTransitionEnd(element, callback, transitionProperty = 'all', once = false) {
  const fn = (e) => {
    const { propertyName, type, target } = e;
    // Check to see if target and element are the same element.
    if (target !== element) {
      return ;
    }

    if (transitionProperty !== 'all' && propertyName !== transitionProperty) {
      return;
    }

    if (once) {
      element.removeEventListener(type, fn, true);
    }

    run(null, callback, e);
  };

  element.addEventListener(transitionEndEventName, fn, true);
}
@adrigzr
Copy link
Contributor

adrigzr commented Jan 16, 2019

Hi! It works as intended for the helper, but non-intended for the modal behaviour. Maybe we can add that as an option to the helper.

This helper needs a deep rework. We found out that when once=false you cannot remove the listener easily.

I'll work on this issue. Thanks for the report!

adrigzr pushed a commit that referenced this issue Sep 28, 2020
# [2.4.0](v2.3.0...v2.4.0) (2020-09-28)

### Bug Fixes

* **modal:** allow reopen `resolve` and `reject` methods ([9f02276](9f02276))

### Features

* migrate to ES6 classes ([b2a0781](b2a0781))
* **on-transition-end:** only listen for transitions on target ([a09dbd6](a09dbd6)), closes [#43](#43)
@adrigzr
Copy link
Contributor

adrigzr commented Sep 28, 2020

🎉 This issue has been resolved in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

2 participants