Skip to content

fix():generateTrigger在多层shadow元素中使用的异常 #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/hooks/useWinClick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function useWinClick(
popupEle: HTMLElement,
mask: boolean,
maskClosable: boolean,
inPopupOrChild: (target: EventTarget) => boolean,
inPopupOrChild: (target: EventTarget,composedPathTargetList:EventTarget[]) => boolean,
triggerOpen: (open: boolean) => void,
) {
const openRef = React.useRef(open);
Expand All @@ -19,8 +19,8 @@ export default function useWinClick(
// Click to hide is special action since click popup element should not hide
React.useEffect(() => {
if (clickToHide && popupEle && (!mask || maskClosable)) {
const onTriggerClose = ({ target }: MouseEvent) => {
if (openRef.current && !inPopupOrChild(target)) {
const onTriggerClose = (e: MouseEvent) => {
if (openRef.current && !inPopupOrChild(e.target,e.composedPath())) {
triggerOpen(false);
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export function generateTrigger(
const originChildProps = child?.props || {};
const cloneProps: typeof originChildProps = {};

const inPopupOrChild = useEvent((ele: any) => {
const inPopupOrChild = useEvent((ele: any,composedPathTargetList:EventTarget[]) => {
const childDOM = targetEle;

return (
Expand All @@ -284,7 +284,7 @@ export function generateTrigger(
ele === popupEle ||
Object.values(subPopupElements.current).some(
(subPopupEle) => subPopupEle?.contains(ele) || ele === subPopupEle,
)
)||composedPathTargetList.some(tar=>targetEle===tar)
);
});

Expand Down