Skip to content

Commit 449adb0

Browse files
authored
fix: setContainer in onBeforeMount for drawer (#6986)
* fix: setContainer in onBeforeMount for drawer * fix: add judgement
1 parent 4428423 commit 449adb0

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

components/_util/Portal.tsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,24 @@ export default defineComponent({
2323
// getContainer 不会改变,不用响应式
2424
let container: HTMLElement;
2525
const { shouldRender } = useInjectPortal();
26+
27+
function setContainer() {
28+
if (shouldRender.value) {
29+
container = props.getContainer();
30+
}
31+
}
32+
2633
onBeforeMount(() => {
2734
isSSR = false;
35+
// drawer
36+
setContainer();
2837
});
2938
onMounted(() => {
30-
if (shouldRender.value) {
31-
container = props.getContainer();
32-
}
39+
if (container) return;
40+
// https://github.com/vueComponent/ant-design-vue/issues/6937
41+
setContainer();
3342
});
43+
3444
const stopWatch = watch(shouldRender, () => {
3545
if (shouldRender.value && !container) {
3646
container = props.getContainer();

components/message/useMessage.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ const Holder = defineComponent({
9090
closable: false,
9191
closeIcon: mergedCloseIcon,
9292
duration: props.duration ?? DEFAULT_DURATION,
93-
getContainer: () =>
94-
props.staticGetContainer?.() || getPopupContainer.value?.() || document.body,
93+
getContainer: props.staticGetContainer ?? getPopupContainer.value,
9594
maxCount: props.maxCount,
9695
onAllRemoved: props.onAllRemoved,
9796
});

0 commit comments

Comments
 (0)