Skip to content

Commit

Permalink
fix(useClickAway): callback shouldn't called when clicked on dynamic …
Browse files Browse the repository at this point in the history
…element
  • Loading branch information
liuyib committed Apr 24, 2024
1 parent 3ba7cb6 commit d3fb08d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/hooks/src/useClickAway/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export default function useClickAway<T extends Event = Event>(

useEffectWithTarget(
() => {
const handler = (event: any) => {
const handler = (event: T) => {
const targets = Array.isArray(target) ? target : [target];
if (
targets.some((item) => {
const targetElement = getTargetElement(item);
return !targetElement || targetElement.contains(event.target);
return !targetElement || event.composedPath().includes(targetElement);
})
) {
return;
Expand Down

0 comments on commit d3fb08d

Please sign in to comment.