Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: setContainer in onBeforeMount for drawer #6986

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions components/_util/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,24 @@ export default defineComponent({
// getContainer 不会改变,不用响应式
let container: HTMLElement;
const { shouldRender } = useInjectPortal();

function setContainer() {
if (shouldRender.value) {
container = props.getContainer();
}
}

onBeforeMount(() => {
isSSR = false;
// drawer
setContainer();
});
onMounted(() => {
if (shouldRender.value) {
container = props.getContainer();
}
if (container) return;
// https://github.com/vueComponent/ant-design-vue/issues/6937
setContainer();
});

const stopWatch = watch(shouldRender, () => {
if (shouldRender.value && !container) {
container = props.getContainer();
Expand Down
3 changes: 1 addition & 2 deletions components/message/useMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ const Holder = defineComponent({
closable: false,
closeIcon: mergedCloseIcon,
duration: props.duration ?? DEFAULT_DURATION,
getContainer: () =>
props.staticGetContainer?.() || getPopupContainer.value?.() || document.body,
getContainer: props.staticGetContainer ?? getPopupContainer.value,
maxCount: props.maxCount,
onAllRemoved: props.onAllRemoved,
});
Expand Down
Loading