diff --git a/package/component/src/component/dropdown/TeleportWrapper.vue b/package/component/src/component/dropdown/TeleportWrapper.vue new file mode 100644 index 00000000..6e412431 --- /dev/null +++ b/package/component/src/component/dropdown/TeleportWrapper.vue @@ -0,0 +1,33 @@ + + + \ No newline at end of file diff --git a/package/component/src/component/dropdown/index.vue b/package/component/src/component/dropdown/index.vue index 7fe8217f..d86129fd 100644 --- a/package/component/src/component/dropdown/index.vue +++ b/package/component/src/component/dropdown/index.vue @@ -30,6 +30,7 @@ import { ElementScrollRect, DropdownContext, } from "./interface"; +import TeleportWrapper from './TeleportWrapper.vue'; export type DropdownTrigger = "click" | "hover" | "focus" | "contextMenu"; @@ -52,7 +53,7 @@ export interface LayDropdownProps { mouseLeaveDelay?: number; focusDelay?: number; alignPoint?: boolean; - popupContainer?: string | HTMLElement | undefined; + popupContainer?: string | undefined; } const props = withDefaults(defineProps(), { @@ -77,7 +78,7 @@ const props = withDefaults(defineProps(), { }); const childrenRefs = new Set>(); -const dropdownCtx = inject(dropdownInjectionKey, undefined); +const dropdownCtx = inject(dropdownInjectionKey, undefined); const dropdownRef = shallowRef(); const contentRef = shallowRef(); const contentStyle = ref({}); @@ -87,8 +88,7 @@ const openState = ref(false); const containerRef = computed(() => props.popupContainer - ? // @ts-ignore - document.querySelector(props.popupContainer) ?? document.body + ? document.querySelector(props.popupContainer) ?? document.body : dropdownRef.value ) as ComputedRef; @@ -612,7 +612,7 @@ defineExpose({ open, hide, toggle });
- +
-
+ diff --git a/package/document-component/src/document/zh-CN/components/dropdown.md b/package/document-component/src/document/zh-CN/components/dropdown.md index c3a35089..9fc962a9 100644 --- a/package/document-component/src/document/zh-CN/components/dropdown.md +++ b/package/document-component/src/document/zh-CN/components/dropdown.md @@ -23,6 +23,17 @@ +    + + 下拉菜单 + +