瀏覽代碼

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

Netfan 1 月之前
父節點
當前提交
0c3dd92592
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      packages/utils/src/helpers/get-popup-container.ts

+ 6 - 2
packages/utils/src/helpers/get-popup-container.ts

@@ -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
+  );
 }