Skip to content

Commit

Permalink
fix(useFloating): set dataRef openEvent to undefined on close (#…
Browse files Browse the repository at this point in the history
…2853)

* fix(useFloating): set dataRef openEvent to undefined on close

* changeset
  • Loading branch information
atomiks committed Apr 10, 2024
1 parent 7f36f14 commit e2ce05d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/nice-beds-change.md
@@ -0,0 +1,5 @@
---
'@floating-ui/react': patch
---

fix(useFloating): set `dataRef` `openEvent` property to `undefined` on close. Fixes a minor issue when `useHover` `restMs` is combined with `useClientPoint` and focus modality was used before hover modality.
4 changes: 1 addition & 3 deletions packages/react/src/hooks/useFloating.ts
Expand Up @@ -67,9 +67,7 @@ export function useFloating<RT extends ReferenceType = ReferenceType>(

const onOpenChange = useEffectEvent(
(open: boolean, event?: Event, reason?: OpenChangeReason) => {
if (open) {
dataRef.current.openEvent = event;
}
dataRef.current.openEvent = open ? event : undefined;
events.emit('openchange', {open, event, reason, nested});
unstable_onOpenChange?.(open, event, reason);
},
Expand Down

0 comments on commit e2ce05d

Please sign in to comment.