Skip to content

Commit f12b240

Browse files
committed
Do not capture child events
1 parent c76fdd2 commit f12b240

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/composables/preventPhantomEvents.spec.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ describe("preventPhantomEvents", () => {
2626
assert.isTrue(onTransitionEnd.notCalled);
2727
});
2828

29+
it("should not block onTransitionEnd originating from children", () => {
30+
wrapper.setProps({ active: true });
31+
const event = { timeStamp: Date.now(), target: "a", currentTarget: "b" };
32+
wrapper.simulate("transitionEnd", event);
33+
assert.isTrue(onTransitionEnd.called);
34+
});
35+
2936
it("should call onTransitionEnd", () => {
3037
wrapper.setProps({ active: true });
3138
const event = { timeStamp: Date.now() + 20 };

src/composables/preventPhantomEvents.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ export const preventPhantomEvents = isolate(
3434
onTransitionEnd: ({onTransitionEnd}) => (e: TransitionEvent) => {
3535
if (!onTransitionEnd) { return; }
3636

37+
if (e.target !== e.currentTarget) {
38+
onTransitionEnd(e);
39+
return;
40+
}
41+
3742
// Skip transitionEnd that comes <= 10ms after (reversing) a transition.
3843
// In most cases this came from the previous transition.
3944
let compareWith = lastTriggerTime;

0 commit comments

Comments
 (0)