Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Commit

Permalink
fix: toggle repeated clicks with inner target element (#1002)
Browse files Browse the repository at this point in the history
* fix: toggle repeated clicks with inner target element

* test: fix events
  • Loading branch information
atomiks authored Nov 9, 2021
1 parent 475b308 commit 34a8cf2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/createTippy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ export default function createTippy(

// Clicked on the event listeners target
if (
normalizeToArray(instance.props.triggerTarget || reference).indexOf(
actualTarget as Element
) !== -1
normalizeToArray(instance.props.triggerTarget || reference).some((el) =>
actualContains(el, actualTarget as Element)
)
) {
if (currentInput.isTouch) {
return;
Expand Down
18 changes: 18 additions & 0 deletions test/integration/props.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,24 @@ describe('trigger', () => {

expect(instance.state.isVisible).toBe(false);
});

it('toggles on repeated clicks with inner element target', () => {
const inner = h();
const outer = h();
outer.appendChild(inner);

const instance = tippy(outer, {trigger: 'click'});

fireEvent.mouseDown(inner, {bubbles: true});
fireEvent.click(inner, {bubbles: true});

expect(instance.state.isVisible).toBe(true);

fireEvent.mouseDown(inner, {bubbles: true});
fireEvent.click(inner, {bubbles: true});

expect(instance.state.isVisible).toBe(false);
});
});

describe('click focus', () => {
Expand Down

0 comments on commit 34a8cf2

Please sign in to comment.