Skip to content

Commit 0c3dd92

Browse files
authored
fix: getPopupContainer will return closet form first (#5612)
1 parent d33261d commit 0c3dd92

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/**
2-
* Returns the parent node of the given element or the document body if the element is not provided.it
2+
* If the node is holding inside a form, return the form element,
3+
* otherwise return the parent node of the given element or
4+
* the document body if the element is not provided.
35
*/
46
export function getPopupContainer(node?: HTMLElement): HTMLElement {
5-
return (node?.parentNode as HTMLElement) ?? document.body;
7+
return (
8+
node?.closest('form') ?? (node?.parentNode as HTMLElement) ?? document.body
9+
);
610
}

0 commit comments

Comments
 (0)