Skip to content

Commit

Permalink
fix: leaving hovered state when pointer hovers child element (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede authored May 29, 2024
1 parent d237079 commit a8a5624
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/features/eventListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ export function registerEventListeners<T extends string, V extends MotionVariant
hovered.value = false
tapped.value = false
})
useEventListener(target as any, 'mouseout', () => {
hovered.value = false
tapped.value = false
})
}

// Tapped
Expand Down
11 changes: 9 additions & 2 deletions tests/components.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,16 @@ describe.each([

expect(el.style.transform).toEqual('scale(1.2) translateZ(0px)')

// Should return to initial
// Should do nothing on 'mouseout'
await wrapper.trigger('mouseout')
// TODO: figure out a better way to test if a variant is not triggered than timeouts
await nextTick()
await new Promise((resolve) => setTimeout(resolve, 1000))
await waitForMockCalls(onComplete, 0)

// Should return to initial, 'mouseleave' triggers when pointer left element and all descendants
await wrapper.trigger('mouseleave')
await waitForMockCalls(onComplete)
await waitForMockCalls(onComplete, 1)

expect(el.style.transform).toEqual('scale(1) translateZ(0px)')
})
Expand Down

0 comments on commit a8a5624

Please sign in to comment.