We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d33261d commit 0c3dd92Copy full SHA for 0c3dd92
packages/utils/src/helpers/get-popup-container.ts
@@ -1,6 +1,10 @@
1
/**
2
- * 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,
3
+ * otherwise return the parent node of the given element or
4
+ * the document body if the element is not provided.
5
*/
6
export function getPopupContainer(node?: HTMLElement): HTMLElement {
- return (node?.parentNode as HTMLElement) ?? document.body;
7
+ return (
8
+ node?.closest('form') ?? (node?.parentNode as HTMLElement) ?? document.body
9
+ );
10
}
0 commit comments