Skip to content

Commit

Permalink
fix(useDismiss): targetRootAncestor for third party outside presses (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Nov 25, 2023
1 parent c6e899d commit 9170b9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/calm-schools-approve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@floating-ui/react": patch
---

fix(useDismiss): `targetRootAncestor` check for third party outside presses

The Grammarly extension no longer closes upon clicking when inside floating elements.
2 changes: 1 addition & 1 deletion packages/react/src/hooks/useDismiss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export function useDismiss<RT extends ReferenceType = ReferenceType>(
let targetRootAncestor = isElement(target) ? target : null;
while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
const nextParent = getParentNode(targetRootAncestor);
if (nextParent === getDocument(floating).body || !isElement(nextParent)) {
if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
break;
} else {
targetRootAncestor = nextParent;
Expand Down

0 comments on commit 9170b9e

Please sign in to comment.