Browse Source

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

pull/5613/head
Netfan 12 months ago
committed by GitHub
parent
commit
0c3dd92592
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      packages/utils/src/helpers/get-popup-container.ts

8
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
);
}

Loading…
Cancel
Save