fix: getPopupContainer will return closet form first (#5612)

This commit is contained in:
Netfan 2025-02-25 22:07:56 +08:00 committed by GitHub
parent d33261d0c2
commit 0c3dd92592
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,10 @@
/**
* Returns the parent node of the given element or the document body if the element is not provided.it
* If the node is holding inside a form, return the form element,
* otherwise return the parent node of the given element or
* the document body if the element is not provided.
*/
export function getPopupContainer(node?: HTMLElement): HTMLElement {
return (node?.parentNode as HTMLElement) ?? document.body;
return (
node?.closest('form') ?? (node?.parentNode as HTMLElement) ?? document.body
);
}